package com.easyclearance.service.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.jsoup.Connection;
import org.jsoup.Connection.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.chuguobao.util.SingaporeIcaRegUtil;
import com.chuguobao.util.ThailandRegUtil;
import com.chuguobao.util.view.thailand.BaseModel;
import com.chuguobao.util.view.thailand.PersonInfoView;
import com.chuguobao.util.view.thailand.RespView;
import com.chuguobao.util.view.thailand.TravellerResModel;
import com.chuguobao.util.view.thailand.TripInfoView;
import com.easyclearance.baseutil.DateUtil;
import com.easyclearance.baseutil.FileControl;
import com.easyclearance.baseutil.HttpUtil;
import com.easyclearance.baseutil.MailUtil;
import com.easyclearance.baseutil.StringUtil;
import com.easyclearance.countryRegUtil.MalaysiaMadcRegUtil;
import com.easyclearance.dao.EnumTravelMapper;
import com.easyclearance.dao.LeaderInfoMapper;
import com.easyclearance.dao.LeadercodeMapper;
import com.easyclearance.dao.LoginInfoMapper;
import com.easyclearance.dao.MailInfoMapper;
import com.easyclearance.dao.MalaysiatravinfoMapper;
import com.easyclearance.dao.OrderInfoMapper;
import com.easyclearance.dao.OrderTipMapper;
import com.easyclearance.dao.OrdertravpassportMapper;
import com.easyclearance.dao.PassportInfoMapper;
import com.easyclearance.dao.PriceInfoMapper;
import com.easyclearance.dao.SingaporeTravInfoMapper;
import com.easyclearance.dao.ThailanTravInfoMapper;
import com.easyclearance.dao.TravbaoOrderMapper;
import com.easyclearance.dao.TravelCodeRelationMapper;
import com.easyclearance.dao.TravelitineraryMapper;
import com.easyclearance.dao.TravinfoCodeMapper;
import com.easyclearance.dao.WxuserInfoMapper;
import com.easyclearance.entity.EnumTravel;
import com.easyclearance.entity.LeaderInfo;
import com.easyclearance.entity.Leadercode;
import com.easyclearance.entity.LoginInfo;
import com.easyclearance.entity.MailInfo;
import com.easyclearance.entity.Malaysiatravinfo;
import com.easyclearance.entity.OrderInfo;
import com.easyclearance.entity.OrderTip;
import com.easyclearance.entity.Ordertravpassport;
import com.easyclearance.entity.PassportInfo;
import com.easyclearance.entity.PriceInfo;
import com.easyclearance.entity.SingaporeTravInfo;
import com.easyclearance.entity.ThailandTravInfo;
import com.easyclearance.entity.TravInfoCode;
import com.easyclearance.entity.TravbaoOrder;
import com.easyclearance.entity.TravelCodeRelation;
import com.easyclearance.entity.Travelitinerary;
import com.easyclearance.entity.WxuserInfo;
import com.easyclearance.service.TravInfoService;
import com.easyclearance.service.WxuserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.hutool.extra.pinyin.PinyinUtil;
import cn.hutool.poi.excel.ExcelReader;

@Service("travbaoService")
public class TravInfoServiceImpl implements TravInfoService {
	
	public static final Logger logger = Logger.getLogger(TravInfoServiceImpl.class);
	@Autowired
	private MailUtil mailUtil;
	@Autowired
	private MailInfoMapper mailInfoMapper;
	@Autowired
	private LoginInfoMapper loginInfoMapper;
	@Autowired
	private OrderTipMapper orderTipMapper;
//	@Autowired
//	private OrderTipsMapper orderTipsMapper;
	@Autowired
	private OrderInfoMapper orderInfoMapper;
	@Autowired
	private PriceInfoMapper priceInfoMapper;
	@Autowired
	private LeadercodeMapper leadercodeMapper;
	@Autowired
	private LeaderInfoMapper leaderInfoMapper;
	@Autowired
	private TravinfoCodeMapper travinfoCodeMapper;
	@Autowired
	private PassportInfoMapper passportInfoMapper;
	@Autowired
	private EnumTravelMapper enumTravelMapper;
	@Autowired
	private WxuserInfoMapper wxuserInfoMapper;
	@Autowired
	private TravelitineraryMapper travelitineraryMapper;
	@Autowired
	private ThailanTravInfoMapper thailanTravInfoMapper;
	@Autowired
	private MalaysiatravinfoMapper malaysiatravinfoMapper;
	@Autowired
	private SingaporeTravInfoMapper singaporeTravIndoMapper;
	@Autowired
	private OrdertravpassportMapper ordertravpassportMapper;
	@Autowired
	private TravelCodeRelationMapper travelCodeRelationMapper;
	@Autowired
	private WxuserService wxuserService;
	
	
	//驱动
	private final String chromeDriver = "C:\\Program Files\\chromedriver\\chromedriver.exe";
	//验证码存储位置
	private final String tempOcrDictionary = "C:\\temp";
	//浏览器缓存
	private final String chromeCacheDictionary = "C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\User Data\\Default";

	
	@Override
	public Map<String, Object> getLeaderInfo(Map<String, Object> paramaMap) {
		// TODO Auto-generated method stub
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			if (Objects.nonNull(paramaMap) && paramaMap.containsKey("code")) {
				String code = paramaMap.get("code").toString();
				//获取领队信息id
				Leadercode leaderCodeInfo = leadercodeMapper.selectOne(new QueryWrapper<Leadercode>().eq("tl_code", code).eq("tl_code_status", 1));
				if (Objects.nonNull(leaderCodeInfo)) {
					String tlid = leaderCodeInfo.getTlid();
					//获取领队信息
					LeaderInfo leaderInfo = leaderInfoMapper.selectById(tlid);
					if (Objects.nonNull(leaderInfo)) {
						String tlName = leaderInfo.getTlName();
						//获取旅行信息
						resultMap.put("tlName", tlName);
					}
				}
			}else {
				throw new Exception("团组码不可以为空");
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e);
		}
		return resultMap;
	}
	
	@Override
	public Map<String, Object> createOrderInfo(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			if (Objects.nonNull(paraMap)) {
				String code = "";
				if (paraMap.containsKey("code")) {
					code = paraMap.get("code").toString();
				}else {
					throw new Exception("编码不能为空");
				}
				String userId = "";
				if (paraMap.containsKey("userId")) {
					userId = paraMap.get("userId").toString();
				}else {
					throw new Exception("openid不能为空");
				}
				resultMap = createOrderInfoPublicMethod(paraMap, code, userId);
			}else {
				throw new Exception("未获取到前端传递的参数");
			}
		} catch (Exception e) {
			// TODO: handle exception
			logger.error("创建护照信息1:"+e);
			throw new RuntimeException(e);
		}
		return resultMap;
	}

	@Override
	public Map<String, Object> createOrderInfoPublicMethod(Map<String, Object> paraMap,String code,String userId) {
		// TODO Auto-generated method stub
		Map<String, Object> resultMap = new HashMap<>();
		try {
			String ec_merchant_order__number = "";
			List<Ordertravpassport> linkedList = new LinkedList<>();
			if (Objects.nonNull(paraMap.get("passpportArr"))) {
				JSONArray parseArray = JSONArray.parseArray(JSON.toJSONString(paraMap.get("passpportArr")));
				for (int i = 0; i < parseArray.size(); i++) {
					Ordertravpassport ordertravpassport = new Ordertravpassport();
					JSONObject jsonObject = parseArray.getJSONObject(i);
					logger.error("----user upload passportInfo----"+JSON.toJSONString(jsonObject));
					String guPassportNum = "";
					if (jsonObject.containsKey("guPassportNum")) {
						guPassportNum = jsonObject.getString("guPassportNum");
					}else {
						throw new Exception("护照号不能为空");
					}
					//泰国电子入境需要职业信息
					String occupationCn = null;
					String occupationEn = null;
					if (jsonObject.containsKey("occupationCn") && jsonObject.containsKey("occupationEn")) {
						occupationCn = jsonObject.getString("occupationCn");;
						occupationEn = jsonObject.getString("occupationEn");;
					}
					//创建护照信息对象
					String passid = "";
					//判断是否存在护照信息
					List<PassportInfo> passInfo = passportInfoMapper.selectList(new QueryWrapper<PassportInfo>().eq("gu_passport_num",guPassportNum));
					if (Objects.nonNull(passInfo)) {
						//首先判断一下是否支付过
						PassportInfo passportInfo = passInfo.get(0);
						passid = passportInfo.getId();
						//获取旅行信息
						Leadercode learCode = leadercodeMapper.selectOne(new QueryWrapper<Leadercode>().eq("tl_code", code));
						logger.error("团组码信息"+JSON.toJSONString(learCode));
						if (Objects.nonNull(learCode)) {
							String id = learCode.getId();
							//获取行程表
							Travelitinerary travelitinerary = travelitineraryMapper.selectOne(new QueryWrapper<Travelitinerary>().eq("tlid", id));
							if (Objects.nonNull(travelitinerary)) {
								String id2 = travelitinerary.getId();
								//获取旅行个信息
								List<Ordertravpassport> ordertravpassportsList = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("travid", id2).eq("ecppid", passid));
								if (CollectionUtils.isNotEmpty(ordertravpassportsList)) {
									ordertravpassport.setId(ordertravpassportsList.get(0).getId());
									List<String> orderidList = ordertravpassportsList.stream().filter(t->t.getOrderid()!=null).map(tt->tt.getOrderid()).collect(Collectors.toList());
									if (CollectionUtils.isNotEmpty(orderidList)) {
										List<OrderInfo> orderInfos = orderInfoMapper.selectList(new QueryWrapper<OrderInfo>().in("id", orderidList).eq("ec_pay_status", 1));
										if (CollectionUtils.isNotEmpty(orderInfos)) {
											throw new Exception("护照："+guPassportNum+"在该行程存在已经支付的订单，请勿重复支付");
										}else {
											if (StringUtils.isNotEmpty(occupationCn) && StringUtils.isNotEmpty(occupationEn)) {
												passportInfo.setOccupationCn(occupationCn);
												passportInfo.setOccupationEn(occupationEn);
												passportInfoMapper.updateById(passportInfo);
											}
											logger.error("不存在已经支付的订单");
										}
									}else {
										List<String> orderidLists = ordertravpassportsList.stream().filter(t->t.getOrderid()==null).map(tt->tt.getOrderid()).collect(Collectors.toList());
										if (CollectionUtils.isNotEmpty(orderidLists)) {
											if (StringUtils.isNotEmpty(occupationCn) && StringUtils.isNotEmpty(occupationEn)) {
												passportInfo.setOccupationCn(occupationCn);
												passportInfo.setOccupationEn(occupationEn);
												passportInfoMapper.updateById(passportInfo);
											}
											logger.error("在该团组信息中查询到该护照信息");
										}else {
											throw new Exception("未在该团组信息中查询到您的护照信息，请联系领队确认是否添加了您的护照信息");
										}
									}
								}else {
									throw new Exception("未在该团组信息中查询到您的护照信息，请联系领队确认是否添加了您的护照信息");
								}
							}
						}
					}else {
						throw new Exception("未识别到正确的护照信息，请重新识别。");
					}
					ec_merchant_order__number = ec_merchant_order__number+guPassportNum;
					//关系表idd
					ordertravpassport.setEcppid(passid);
					ordertravpassport.setPubts(new Date());
					linkedList.add(ordertravpassport);
				}
			}
			logger.error("关系表:"+JSON.toJSONString(linkedList));
			String tipsInfo = "";
			OrderTip orderTip = orderTipMapper.selectOne(new QueryWrapper<OrderTip>().eq("country_code", "ALL").eq("status", 1));
			if (Objects.nonNull(orderTip)) {
				tipsInfo = orderTip.getOrderTips();
			}
			//获取旅行信息
			Leadercode learCode = leadercodeMapper.selectOne(new QueryWrapper<Leadercode>().eq("tl_code", code));
			logger.error("团组码信息"+JSON.toJSONString(learCode));
			if (Objects.nonNull(learCode)) {
				String id = learCode.getId();
				//获取行程表
				Travelitinerary travelitinerary = travelitineraryMapper.selectOne(new QueryWrapper<Travelitinerary>().eq("tlid", id));
				if (Objects.nonNull(travelitinerary)) {
					String travelitineraryid = travelitinerary.getId();
					String titName = travelitinerary.getTitName();
					//人数
					BigDecimal personNum = BigDecimal.valueOf(linkedList.size());
					//获取金额
					BigDecimal payment = personNum.multiply(travelitinerary.getTitPrice());
					//创建订单
					OrderInfo orderInfo = new OrderInfo();
					String orderrid = StringUtil.getId();
					orderInfo.setId(orderrid);
					orderInfo.setUserId(userId);
					orderInfo.setEcName(titName);
					orderInfo.setEcPayment(payment);
					orderInfo.setEcPersonNum(personNum);
					orderInfo.setEcStatus(Short.parseShort("1"));
					orderInfo.setEcMerchantOrderNumber(code+ec_merchant_order__number);
					orderInfo.setPubts(new Date());
					orderInfoMapper.insert(orderInfo);
					//回写关系表
					linkedList.stream().forEach(t->{
						t.setOrderid(orderrid);
						t.setTravid(travelitineraryid);
						ordertravpassportMapper.updateById(t);
					});
					//判断是否需要支付
					if (payment.compareTo(BigDecimal.ZERO)==0) {
						resultMap.put("isPay", 0);
						updateOrderInfoStatus(orderrid);
					}else {
						resultMap.put("isPay", 1);
					}
					resultMap.put("orderId", orderrid);
					//信息集合
					resultMap.put("orderTips", tipsInfo);
				}else {
					throw new Exception("未获取到行程信息");
				}
			}else {
				throw new Exception("未获取到编号对应信息");
			}
		} catch (Exception e) {
			// TODO: handle exception
			logger.error("创建护照信息:"+e);
			throw new RuntimeException(e.getMessage());
		}
		return resultMap;
	}
	
	@Override
	public Map<String, Object> getOrderlist(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		try {
			if (paraMap.containsKey("userId")) {
				if (paraMap.containsKey("pageIndex") && paraMap.containsKey("pageSize")) {
					List<Map<String, Object>> linkedList = new LinkedList<Map<String, Object>>();
					String userid = paraMap.get("userId").toString();
					Integer pageSize = Integer.parseInt(paraMap.get("pageSize").toString());
					Integer pageIndex = Integer.parseInt(paraMap.get("pageIndex").toString());
					//10天以内的
					Calendar instance = Calendar.getInstance();
					instance.add(Calendar.DATE, -10);
					String beforeTenDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(instance.getTime());
					//获取订单列表
					PageHelper.startPage(pageIndex, pageSize, true);
					//条件
					QueryWrapper<OrderInfo> queryWrapper = new QueryWrapper<>();
					queryWrapper.eq("user_id", userid);
					queryWrapper.eq("ec_status", Short.parseShort("1"));
					queryWrapper.ge("pubts", beforeTenDate);
					queryWrapper.orderByDesc("pubts");
					List<OrderInfo> selectList = orderInfoMapper.selectList(queryWrapper);
					PageInfo<OrderInfo> pageInfo = new PageInfo<>(selectList);
					List<OrderInfo> records = pageInfo.getList();
					logger.error("list:"+JSON.toJSONString(records));
					for (int i = records.size()-1; i >= 0; i--) {
						OrderInfo orderInfo = records.get(i);
						String id = orderInfo.getId();
						String ecName = orderInfo.getEcName();
						short ecPayStatus = orderInfo.getEcPayStatus();
						Date pubts = orderInfo.getPubts();
						String pubt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(pubts);
						Map<String, Object> orderMap = new HashMap<String, Object>();
						orderMap.put("id", id);
						orderMap.put("pubts", pubt);
						orderMap.put("ecName", ecName);
						orderMap.put("ecPayStatus", ecPayStatus);
						//获取关系表
						List<Map<String, Object>> jsonArray = new LinkedList<>();
						List<Ordertravpassport> ordertravpassports = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("orderid", id));
						if (CollectionUtils.isNotEmpty(ordertravpassports)) {
							for (int j = 0; j < ordertravpassports.size(); j++) {
								Ordertravpassport ordertravpassport = ordertravpassports.get(j);
								Map<String, Object> hashMap = new HashMap<>();
								String ecppid = ordertravpassport.getEcppid();
								PassportInfo passportInfo = passportInfoMapper.selectById(ecppid);
								if (Objects.nonNull(passportInfo)) {
									String guName = passportInfo.getGuName();
									String guFamiNameEn = passportInfo.getGuFamiNameEn();
									String guFirstNameEn = passportInfo.getGuFirstNameEn();
									String guPassportNum = passportInfo.getGuPassportNum();
									
									hashMap.put("guName", guName);
									hashMap.put("guFamiNameEn", guFamiNameEn);
									hashMap.put("guFirstNameEn", guFirstNameEn);
									hashMap.put("guPassportNum", guPassportNum);
									jsonArray.add(hashMap);
								}	
							}
						}
						orderMap.put("passMap", jsonArray);
						linkedList.add(orderMap);
					}
					 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					Collections.sort(linkedList,(t1,t2)->{
						try {
							return simpleDateFormat.parse(t2.get("pubts").toString()).compareTo(simpleDateFormat.parse(t1.get("pubts").toString()));
						} catch (ParseException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						return 1;
					});
					Map<String, Object> resultMap = new HashMap<String, Object>();
					resultMap.put("pageSize", pageSize);
					resultMap.put("recorList", linkedList);
					resultMap.put("pageCurrent", pageIndex);
					resultMap.put("pageCount", pageInfo.getTotal());
					resultMap.put("pageEndIndex", pageInfo.getEndRow());
					resultMap.put("pagePreIndex", pageInfo.getPrePage());
					resultMap.put("pageStartIndex", pageInfo.getStartRow());
					resultMap.put("pageIndex", pageInfo.getNavigatepageNums());
					return resultMap;
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return null;
	}
	
	@Override
	public Map<String, Object> getOrderBaseInfo(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			if (paraMap.containsKey("orderId")) {
				//获取订单id
				String orderid = paraMap.get("orderId").toString();
				OrderInfo orderInfo = orderInfoMapper.selectOne(new QueryWrapper<OrderInfo>().eq("id", orderid));
				if (Objects.nonNull(orderInfo)) {
					short ecPayStatus = orderInfo.getEcPayStatus();
					resultMap.put("orderStatus", ecPayStatus);
//					String ecCountry = orderInfo.getEcCountry();
					if (Objects.equals(ecPayStatus, Short.parseShort("0"))) {
						String ecName = orderInfo.getEcName();
						List<Object> priceList = new LinkedList<>();
						List<Object> passportList = new LinkedList<>();
						List<Object> travelList = new LinkedList<>();
						//获取关联关系
						List<Ordertravpassport> ordertravpassportList = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("orderid", orderid));
						logger.error("订单关系："+JSON.toJSONString(ordertravpassportList));
						String travid = "";
						if (CollectionUtils.isNotEmpty(ordertravpassportList)) {
							for (int i = 0; i < ordertravpassportList.size(); i++) {
								Ordertravpassport ordertravpassport = ordertravpassportList.get(i);
								travid = ordertravpassport.getTravid();
								String ecppid = ordertravpassport.getEcppid();
								//获取护照信息
								Map<String, Object> userInfoMap = new HashMap<String, Object>();
								PassportInfo passport = passportInfoMapper.selectOne(new QueryWrapper<PassportInfo>().eq("id", ecppid));
								logger.error("护照信息："+JSON.toJSONString(passport));
								String guName = passport.getGuName();
								String guFamiNameEn = passport.getGuFamiNameEn();
								String guFirstNameEn = passport.getGuFirstNameEn();
								String guPassportNum = passport.getGuPassportNum();
								userInfoMap.put("guName", guName);
								userInfoMap.put("guFamiNameEn", guFamiNameEn);
								userInfoMap.put("guPassportNum", guPassportNum);
								userInfoMap.put("guFirstNameEn", guFirstNameEn);
								passportList.add(userInfoMap);
							}
							//获取旅行信息
							Travelitinerary travelitinerary = travelitineraryMapper.selectById(travid);
							if (Objects.nonNull(travelitinerary)) {
								String titCode = travelitinerary.getTitCode();
								String[] trIdArr = titCode.split("-");
								for (int j = 0; j < trIdArr.length; j++) {
									Map<String, Object> hashMap = new HashMap<>();
									String ecCountry = trIdArr[j];
									String ecpid = "";
									if (Objects.equals(ecCountry, "0060")) {
										Malaysiatravinfo malatravInfoi = malaysiatravinfoMapper.selectOne(new QueryWrapper<Malaysiatravinfo>().eq("titid", travid).eq("trow", j+1));
										logger.error("旅行信息："+JSON.toJSONString(malatravInfoi));
										//获取价格信息
										 ecpid = malatravInfoi.getEcpid();
										 Date dateofentry = malatravInfoi.getDateofentry();
										 String format = new SimpleDateFormat("MM月dd日").format(dateofentry);
										 hashMap.put("linkey", "dateofentry");
										 hashMap.put("linValue", format);
										 hashMap.put("trow", malatravInfoi.getTrow());
										 hashMap.put("country", "马来西亚");
									}else if (Objects.equals(ecCountry, "0065")) {
										SingaporeTravInfo singaporeTravInfo = singaporeTravIndoMapper.selectOne(new QueryWrapper<SingaporeTravInfo>().eq("titid", travid).eq("trow", j+1));
										logger.error("旅行信息："+JSON.toJSONString(singaporeTravInfo));
										//获取价格信息
										 ecpid = singaporeTravInfo.getEcpid();
										 Date dateofentry = singaporeTravInfo.getDateofentry();
										 String format = new SimpleDateFormat("MM月dd日").format(dateofentry);
										 hashMap.put("linkey", "dateofentry");
										 hashMap.put("linValue", format);
										 hashMap.put("trow", singaporeTravInfo.getTrow());
										 hashMap.put("country", "新加坡");
									}else if (Objects.equals(ecCountry, "0066")) {
										ThailandTravInfo thailandTravInfo = thailanTravInfoMapper.selectOne(new QueryWrapper<ThailandTravInfo>().eq("titid", travid).eq("trow", j+1));
										logger.error("旅行信息："+JSON.toJSONString(thailandTravInfo));
										//获取价格信息
										 ecpid = thailandTravInfo.getEcpid();
										 Date dateofentry = thailandTravInfo.getDateofentry();
										 String format = new SimpleDateFormat("MM月dd日").format(dateofentry);
										 hashMap.put("linkey", "dateofentry");
										 hashMap.put("linValue", format);
										 hashMap.put("trow", thailandTravInfo.getTrow());
										 hashMap.put("country", "泰国");
									}
									logger.error("-----------价格信息-------------------------");
									PriceInfo priceInfo = priceInfoMapper.selectById(ecpid);
									BigDecimal ecpPrice = priceInfo.getEcpPrice();
									BigDecimal ecpDiscount = priceInfo.getEcpDiscount();
									String ecpName = priceInfo.getEcpName();
									Map<String, Object> priceInfoMap = new HashMap<String, Object>();
									priceInfoMap.put("ecpName", ecpName);
									priceInfoMap.put("ecpPrice", ecpPrice);
									priceInfoMap.put("ecpDiscount", ecpDiscount);
									priceInfoMap.put("ecpNum", ordertravpassportList.size());
									travelList.add(hashMap);
									priceList.add(priceInfoMap);
								}
								logger.error("-----------金额信息-------------------------");
								BigDecimal ecPayment = orderInfo.getEcPayment();
								//获取提示信息
								String tipString = "";
								OrderTip ordertip = orderTipMapper.selectOne(new QueryWrapper<OrderTip>().eq("country_code", "ALL").eq("status", 3));
								if (Objects.nonNull(ordertip)) {
									tipString = ordertip.getOrderTips();
								}
								//获取旅行社信息
								String tlid = travelitinerary.getTlid();
								Leadercode leadercode = leadercodeMapper.selectById(tlid);
								if (Objects.nonNull(leadercode)) {
									String tlid2 = leadercode.getTlid();
									LeaderInfo leaderInfo = leaderInfoMapper.selectById(tlid2);
									if (Objects.nonNull(leaderInfo)) {
										String tlTravelAgency = leaderInfo.getTlTravelAgency();
										tipString = tipString.replace("xxx", tlTravelAgency).replace("yyy", ecPayment.toString());
									}
								}
								if (ecPayment.compareTo(BigDecimal.ZERO)==0) {
									resultMap.put("isPay", 0);
								}else {
									resultMap.put("isPay", 1);
								}
								resultMap.put("ecName", ecName);
								resultMap.put("ecPayment", ecPayment);
								resultMap.put("ecPayTips", tipString);
								resultMap.put("priceLsit", priceList);
								resultMap.put("travelList", travelList);
								resultMap.put("ecPayStatus", ecPayStatus);
								resultMap.put("passportList", passportList);
							}else {
								throw new Exception("订单对应的行程信息为空");
							}
						}else {
							throw new Exception("未获取到订单与旅行信息的关系表");
						}
					}else if (Objects.equals(ecPayStatus, Short.parseShort("1"))) {
						List<Ordertravpassport> ordertravpassportList = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("orderid", orderid));
						logger.error("订单关系："+JSON.toJSONString(ordertravpassportList));
						if (CollectionUtils.isNotEmpty(ordertravpassportList)) {
							String travid = "";
							String otpid = "";
							List<Object> passList = new LinkedList<>();
							for (int i = 0; i < ordertravpassportList.size(); i++) {
								Ordertravpassport ordertravpassport = ordertravpassportList.get(i);
								otpid = ordertravpassport.getId();
								travid = ordertravpassport.getTravid();
								Map<String, Object> userInfoMap =  new HashMap<String, Object>();
								String ecppid = ordertravpassport.getEcppid();
								PassportInfo passportInfo = passportInfoMapper.selectOne(new QueryWrapper<PassportInfo>().eq("id", ecppid));
								String guSexEn = passportInfo.getGuSexEn();
								String guFamiNameEn = passportInfo.getGuFamiNameEn();
								String guFirstNameEn = passportInfo.getGuFirstNameEn();
								String guNationalityEn = passportInfo.getGuNationalityEn();
								String guBirthDate = passportInfo.getGuBirthDate();
								Date parse = new SimpleDateFormat("yyyyMMdd").parse(guBirthDate);
								String birthdate = new SimpleDateFormat("dd/MM/yyyy").format(parse);
								String guExpiryDate = passportInfo.getGuExpiryDate();
								Date parse1 = new SimpleDateFormat("yyyyMMdd").parse(guExpiryDate);
								String expiryDate = new SimpleDateFormat("dd/MM/yyyy").format(parse1);
								String guPassportNum = passportInfo.getGuPassportNum();
								userInfoMap.put("guSexEn", guSexEn);
								userInfoMap.put("guBirthDate", birthdate);
								userInfoMap.put("guExpiryDate", expiryDate);
								userInfoMap.put("guPassportNum", guPassportNum);
								userInfoMap.put("guNationalityEn", guNationalityEn);
								userInfoMap.put("guName", guFamiNameEn+" "+guFirstNameEn);
								passList.add(userInfoMap);
							}
							//获取行程表
							Travelitinerary travelitinerary = travelitineraryMapper.selectById(travid);
							if (Objects.nonNull(travelitinerary)) {
								List<Map<String, Object>> travList = new LinkedList<>();
								String titCode = travelitinerary.getTitCode();
								String[] countryCodeArr = titCode.split("-");
								for (int i = 0; i < countryCodeArr.length; i++) {
									String couuntry_code = countryCodeArr[i];
									Map<String, Object> travInfoMap =  new HashMap<String, Object>();
									travInfoMap.put("couuntry_code", couuntry_code);
									if (Objects.equals(couuntry_code, "0060")) {
										Malaysiatravinfo malaTravInfo = malaysiatravinfoMapper.selectOne(new QueryWrapper<Malaysiatravinfo>().eq("titid", travid).eq("trow", i+1));
										if (Objects.nonNull(malaTravInfo)) {
											Integer row = malaTravInfo.getTrow();
											String email = malaTravInfo.getEmail();
											String mobile = malaTravInfo.getMobile();
											String region = malaTravInfo.getRegion();
											String postcode = malaTravInfo.getPostcode();
											String flightno = malaTravInfo.getFlightno();
											Date dateofentry = malaTravInfo.getDateofentry();
											Date dateofleave = malaTravInfo.getDateofleave();
											String entrymethod = malaTravInfo.getEntrymethod();
											String addressofstay = malaTravInfo.getAddressofstay();
											String countryofstay = malaTravInfo.getCountryofstayCn();
											String residentialmode = malaTravInfo.getResidentialmode();
											String cityofresidenceCn = malaTravInfo.getCityofresidenceCn();
											String stateofresidenceCn = malaTravInfo.getStateofresidenceCn();
											String entrydateString = new SimpleDateFormat("dd/MM/yyyy").format(dateofentry);
											String leavedateString = new SimpleDateFormat("dd/MM/yyyy").format(dateofleave);
											//获取pin
											TravelCodeRelation travelCodeRelation = travelCodeRelationMapper.selectOne(new QueryWrapper<TravelCodeRelation>().eq("otpid", otpid).eq("trow", row));
											if (Objects.nonNull(travelCodeRelation)) {
												String tcid = travelCodeRelation.getTcid();
												TravInfoCode travInfoCode = travinfoCodeMapper.selectById(tcid);
												if (Objects.nonNull(travInfoCode)) {
													travInfoMap.put("pinCode", travInfoCode.getCode());
												}
											}
											Date today = new Date();
											long longDay = dateofentry.getTime()-today.getTime();
//											LocalDate enDate = LocalDate.of(dateofentry.getYear(), dateofentry.getMonth(), dateofentry.getDate());
//											logger.error("====enDate---"+enDate);
//											LocalDate toDate = LocalDate.of(today.getYear(), today.getMonth(), today.getDate());
//											logger.error("====toDate---"+toDate);
											long between = longDay/(24*60*60*1000);
											logger.error("距离几天："+between);
											if (between>Long.parseLong("3")) {
												OrderTip orderTip1 = orderTipMapper.selectOne(new QueryWrapper<OrderTip>().eq("status", 5).eq("country_code", couuntry_code));
												if (Objects.nonNull(orderTip1)) {
													Calendar instance = Calendar.getInstance();
													instance.setTime(dateofentry);
													instance.add(Calendar.DATE, -3);
													String format = new SimpleDateFormat("MM月dd日").format(instance.getTime());
													String orderTips = orderTip1.getOrderTips().replace("XXX", format);
													travInfoMap.put("orderTipPre", orderTips);
												}
											}else {
												OrderTip orderTip1 = orderTipMapper.selectOne(new QueryWrapper<OrderTip>().eq("status", 6).eq("country_code", couuntry_code));
												if (Objects.nonNull(orderTip1)) {
													travInfoMap.put("orderTipPre", orderTip1.getOrderTips());
												}
											}
											//获取提示信息
											OrderTip orderTip2 = orderTipMapper.selectOne(new QueryWrapper<OrderTip>().eq("status", 2).eq("country_code", couuntry_code));
											if (Objects.nonNull(orderTip2)) {
												travInfoMap.put("orderTip", orderTip2.getOrderTips());
											}
											travInfoMap.put("trow", row);
											travInfoMap.put("email", email);
											travInfoMap.put("mobile", mobile);
											travInfoMap.put("region", region);
											travInfoMap.put("postcode", postcode);
											travInfoMap.put("flightno", flightno);
											travInfoMap.put("entrymethod", entrymethod);
											travInfoMap.put("dateofentry", entrydateString);
											travInfoMap.put("dateofleave", leavedateString);
											travInfoMap.put("addressofstay", addressofstay);
											travInfoMap.put("countryofstay", countryofstay);
											travInfoMap.put("residentialmode", residentialmode);
											travInfoMap.put("cityofresidenceCn", cityofresidenceCn);
											travInfoMap.put("stateofresidenceCn", stateofresidenceCn);
											travList.add(travInfoMap);
											
										}
									}else if (Objects.equals(couuntry_code, "0065")) {
										SingaporeTravInfo singaporeTravInfo = singaporeTravIndoMapper.selectOne(new QueryWrapper<SingaporeTravInfo>().eq("titid", travid).eq("trow", i+1));
										if (Objects.nonNull(singaporeTravInfo)) {
											Date dateofentry = singaporeTravInfo.getDateofentry();
											logger.error("------"+dateofentry);
											String entitydateString = new SimpleDateFormat("yyyy-MM-dd").format(dateofentry);
											logger.error("====---"+entitydateString);
											travInfoMap.put("dateofentry", entitydateString); 
											Integer row = singaporeTravInfo.getTrow();
											//获取pin
											TravelCodeRelation travelCodeRelation = travelCodeRelationMapper.selectOne(new QueryWrapper<TravelCodeRelation>().eq("otpid", otpid).eq("trow", row));
											if (Objects.nonNull(travelCodeRelation)) {
												String tcid = travelCodeRelation.getTcid();
												TravInfoCode travInfoCode = travinfoCodeMapper.selectById(tcid);
												if (Objects.nonNull(travInfoCode)) {
													travInfoMap.put("pinCode", travInfoCode.getCode());
												}
											}
											Date today = new Date();
											long longDay = dateofentry.getTime()-today.getTime();
//											LocalDate enDate = LocalDate.of(dateofentry.getYear(), dateofentry.getMonth(), dateofentry.getDate());
//											logger.error("====enDate---"+enDate);
//											LocalDate toDate = LocalDate.of(today.getYear(), today.getMonth(), today.getDate());
//											logger.error("====toDate---"+toDate);
											long between = longDay/(24*60*60*1000);
											logger.error("距离几天："+between);
											if (between>Long.parseLong("3")) {
												OrderTip orderTip1 = orderTipMapper.selectOne(new QueryWrapper<OrderTip>().eq("status", 5).eq("country_code", couuntry_code));
												if (Objects.nonNull(orderTip1)) {
													Calendar instance = Calendar.getInstance();
													instance.setTime(dateofentry);
													instance.add(Calendar.DATE, -3);
													String format = new SimpleDateFormat("MM月dd日").format(instance.getTime());
													String orderTips = orderTip1.getOrderTips().replace("XXX", format);
													travInfoMap.put("orderTipPre", orderTips);
												}
											}else {
												OrderTip orderTip1 = orderTipMapper.selectOne(new QueryWrapper<OrderTip>().eq("status", 6).eq("country_code", couuntry_code));
												if (Objects.nonNull(orderTip1)) {
													travInfoMap.put("orderTipPre", orderTip1.getOrderTips());
												}
											}
											//获取提示信息
											OrderTip orderTip2 = orderTipMapper.selectOne(new QueryWrapper<OrderTip>().eq("status", 2).eq("country_code", couuntry_code));
											if (Objects.nonNull(orderTip2)) {
												travInfoMap.put("orderTip", orderTip2.getOrderTips());
											}
											travList.add(travInfoMap);
										}else {
											throw new Exception("未获取到该订单的旅行信息");
										}
									}else if (Objects.equals(couuntry_code, "0066")) {
										ThailandTravInfo thailandTravInfo = thailanTravInfoMapper.selectOne(new QueryWrapper<ThailandTravInfo>().eq("titid", travid).eq("trow", i+1));
										if (Objects.nonNull(thailandTravInfo)) {
											Date dateofentry = thailandTravInfo.getDateofentry();
											logger.error("------"+dateofentry);
											String entitydateString = new SimpleDateFormat("yyyy-MM-dd").format(dateofentry);
											logger.error("====---"+entitydateString);
											travInfoMap.put("dateofentry", entitydateString); 
											Integer row = thailandTravInfo.getTrow();
											//获取pin
											TravelCodeRelation travelCodeRelation = travelCodeRelationMapper.selectOne(new QueryWrapper<TravelCodeRelation>().eq("otpid", otpid).eq("trow", row));
											if (Objects.nonNull(travelCodeRelation)) {
												String tcid = travelCodeRelation.getTcid();
												TravInfoCode travInfoCode = travinfoCodeMapper.selectById(tcid);
												if (Objects.nonNull(travInfoCode)) {
													travInfoMap.put("pinCode", travInfoCode.getCode());
													travInfoMap.put("pinUrl", travInfoCode.getCodeUrl());
												}
											}
											//获取提示信息
											OrderTip orderTip2 = orderTipMapper.selectOne(new QueryWrapper<OrderTip>().eq("status", 2).eq("country_code", couuntry_code));
											if (Objects.nonNull(orderTip2)) {
												travInfoMap.put("orderTip", orderTip2.getOrderTips());
											}
											travList.add(travInfoMap);
										}else {
											throw new Exception("未获取到该订单的旅行信息");
										}
									}
								}
								//获取旅行社信息
								String tlTravelAgency = "";
								String tlid = travelitinerary.getTlid();
								Leadercode leadercode = leadercodeMapper.selectById(tlid);
								if (Objects.nonNull(leadercode)) {
									String tlid2 = leadercode.getTlid();
									LeaderInfo leaderInfo = leaderInfoMapper.selectById(tlid2);
									if (Objects.nonNull(leaderInfo)) {
										 tlTravelAgency = leaderInfo.getTlTravelAgency();
									}
								}
								logger.error("--------组合---------");
								List<Object> inffoList = new LinkedList<>();
								passList.stream().forEach(t->{
									Map<String, Object> jsonMap = new HashMap<String, Object>();
									jsonMap.put("passportList", passList);
									jsonMap.put("travList", travList);
									inffoList.add(jsonMap);
								});
								//获取提示信息
								OrderTip orderTip4 = orderTipMapper.selectOne(new QueryWrapper<OrderTip>().eq("status", 4).eq("country_code", "ALL"));
								if (Objects.nonNull(orderTip4)) {
									String orderTips = orderTip4.getOrderTips().replace("KL", travList.size()+"").replace("xxx", tlTravelAgency);
									resultMap.put("orderTip", orderTips);
								}
								resultMap.put("infoList", inffoList);
							}
						}
					}
				}else {
					throw new Exception("未获取到订单信息");
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
			logger.error("Baseinfo:"+e);
			throw new RuntimeException(e.getMessage());
		}
		return resultMap;
	}
	
	@Override
	public Map<String, Object> createTravInfo(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			if (Objects.nonNull(paraMap)) {
				//创建行程
				Travelitinerary travelitinerary = new Travelitinerary();
				String id = StringUtil.getId();
				travelitinerary.setId(id);
				String titCode = "";
				String titName = "";
				Integer tInteger = 0;
				BigDecimal titPrice = BigDecimal.ZERO;
				List<Object> linkedList = new LinkedList<>();
				if (Objects.nonNull(paraMap.get("travelitinerary"))) {
					JSONArray parseArray = JSONArray.parseArray(JSON.toJSONString(paraMap.get("travelitinerary")));
					for (int i = 0; i < parseArray.size(); i++) {
						JSONObject jsonObject = parseArray.getJSONObject(i);
						if (jsonObject.get("countryCode")!=null && StringUtils.isNotEmpty(jsonObject.getString("countryCode"))) {
							String countryCode = jsonObject.getString("countryCode");
							if (Objects.equals("0060", countryCode)) {
								Malaysiatravinfo malaysiatravinfo = createMalaysiatravinfo(jsonObject,id,i+1);
								//获取一下价格信息
								linkedList.add(malaysiatravinfo);
								titName = Objects.equals(titName, "")? "马来西亚":titName+"-马来西亚";
								titPrice = titPrice.add(getTravelPriceInfo(malaysiatravinfo.getEcpid()));
							}else if (Objects.equals("0065", countryCode)) {
								SingaporeTravInfo singaporeTravInfo = createSingaporeTravInfo(jsonObject,id,i+1);
								linkedList.add(singaporeTravInfo);
								titName = Objects.equals(titName, "")? "新加坡":titName+"-新加坡";
								titPrice = titPrice.add(getTravelPriceInfo(singaporeTravInfo.getEcpid()));
							}else if (Objects.equals("0066", countryCode)) {
								ThailandTravInfo thailandTravInfo = createThailandTravInfo(jsonObject,id,i+1);
								linkedList.add(thailandTravInfo);
								titName = Objects.equals(titName, "")? "泰国":titName+"-泰国";
								titPrice = titPrice.add(getTravelPriceInfo(thailandTravInfo.getEcpid()));
							}
							
							tInteger += 1;
							titCode = Objects.equals(titCode, "")? countryCode:titCode+"-"+countryCode;
						}else {
							throw  new Exception("国家码为空！");
						}
					}
					//领队信息id
					String leaderId = "";
					if (paraMap.get("leaderId")!=null) {
						 leaderId = paraMap.get("leaderId").toString();
					}else {
						throw  new Exception("领队信息id为空");
					}
					String lgId = "";
					if (paraMap.get("lgId")!=null) {
						lgId = paraMap.get("lgId").toString();
					}else {
						throw  new Exception("登录用户信息id为空");
					}
					//团队人数
					Integer titPernum = 0;
					if (paraMap.get("titPernum")!=null) {
						titPernum = Integer.parseInt(paraMap.get("titPernum").toString());
					}else {
						throw  new Exception("titPernum为空");
					}
					//生成四位团组码
					Leadercode createLeadCodeInfo = createLeadCodeInfo(leaderId, "");
					travelitinerary.setTlid(createLeadCodeInfo.getId());
					travelitinerary.setTitNum(tInteger);
					travelitinerary.setTitName(titName);
					travelitinerary.setTitCode(titCode);
					travelitinerary.setTitPrice(titPrice);
					travelitinerary.setPubts(new Date());
					travelitinerary.setTitPernum(titPernum);
					travelitinerary.setLgId(lgId);
					travelitineraryMapper.insert(travelitinerary);
					//写入护照信息
					JSONArray passportInfoList = JSONArray.parseArray(JSON.toJSONString(paraMap.get("passportList")));
					for (int i = 0; i < passportInfoList.size(); i++) {
						//获取护照信息
						PassportInfo passportInfo = JSONObject.parseObject(JSON.toJSONString(passportInfoList.get(i)),PassportInfo.class);
						//判断表中是否存在
						PassportInfo passportInfo2 = passportInfoMapper.selectById(passportInfo.getId());
						if (Objects.nonNull(passportInfo2)) {
							passportInfoMapper.updateById(passportInfo);
						}else {
							passportInfoMapper.insert(passportInfo);
						}
						
						//创建中间表
						Ordertravpassport ordertravpassport = new Ordertravpassport();
						String otpId = StringUtil.getId();
						ordertravpassport.setId(otpId);
						ordertravpassport.setEcppid(passportInfo.getId());
						ordertravpassport.setTravid(id);
						ordertravpassport.setPubts(new Date());
						ordertravpassportMapper.insert(ordertravpassport);
					}
					//更新人数
					travelitinerary.setTitPernum(passportInfoList.size());
					travelitineraryMapper.updateById(travelitinerary);
					resultMap.put("travinfo", linkedList);
					resultMap.put("portList", passportInfoList);
					resultMap.put("travcode", createLeadCodeInfo.getTlCode());
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			throw new RuntimeException(e.getMessage());
		}
		return resultMap;
	}
	
	@Override
	public BigDecimal getTravelPriceInfo(String priceInfoId) {
		// TODO Auto-generated method stub
		BigDecimal bigDecimal = BigDecimal.ZERO;
		try {
//			logger.error("价格信息id:"+priceInfoId);
			PriceInfo priceInfo = priceInfoMapper.selectById(priceInfoId);
//			logger.error("价格信息:"+JSON.toJSONString(priceInfo));
			if (Objects.nonNull(priceInfo)) {
				bigDecimal = priceInfo.getEcpPrice().multiply(priceInfo.getEcpDiscount()).subtract(priceInfo.getEcpOtherDiscount());
			}
//			logger.error("最终价格:"+priceInfo.getEcpPrice().multiply(priceInfo.getEcpDiscount()));
//			logger.error("最终价格:"+priceInfo.getEcpPrice().multiply(priceInfo.getEcpDiscount()).subtract(priceInfo.getEcpOtherDiscount()));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return bigDecimal;
	}
	@Override
	public ThailandTravInfo createThailandTravInfo(JSONObject paraMap,String id,Integer row) {
		// TODO Auto-generated method stub
		logger.error("泰国旅行信息"+JSON.toJSONString(paraMap));
		ThailandTravInfo thailandTravInfo = new ThailandTravInfo();
		try {
			String iid = StringUtil.getId();
			thailandTravInfo.setId(iid);
			thailandTravInfo.setTrow(row);
			//获取参数
			//入境日期
			if (paraMap.get("dateofentry")!=null) {
				String dateofentryString = paraMap.get("dateofentry").toString();
				Date dateofentry = new SimpleDateFormat("dd/MM/yyyy").parse(dateofentryString);
				thailandTravInfo.setDateofentry(dateofentry);
			}else {
				throw  new Exception("入境日期为空");
			}

			//居住地 旅行目的
			if (paraMap.get("purposeoftravel")!=null && paraMap.get("placeOfResidence")!=null) {
				String purposeoftravel = paraMap.get("purposeoftravel").toString();
				String placeOfResidence = paraMap.get("placeOfResidence").toString();
				thailandTravInfo.setPurposeoftravel(purposeoftravel);
				thailandTravInfo.setPlaceOfResidence(placeOfResidence);
			}else {
				throw  new Exception("居住地/旅行目的为空");
			}
			//出发国家，出发前滞留的国家
			if (paraMap.get("departureCountry")!=null && paraMap.get("stayBeforeEntryCountry")!=null) {
				String departureCountry = paraMap.get("departureCountry").toString();
				String stayBeforeEntryCountry = paraMap.get("stayBeforeEntryCountry").toString();
				thailandTravInfo.setDepartureCountry(departureCountry);
				thailandTravInfo.setStayBeforeEntryCountry(stayBeforeEntryCountry);
			}else {
				throw  new Exception("出发国家/出发前滞留国家为空");
			}
			//入境方式 航班号
			if (paraMap.get("entryMethod")!=null && paraMap.get("flightNo")!=null) {
				String entrymethod = paraMap.get("entryMethod").toString();
				String flightno = paraMap.get("flightNo").toString();
				thailandTravInfo.setEntryMethod(entrymethod);
				thailandTravInfo.setFlightNo(flightno);
			}else {
				throw  new Exception("入境方式或航班号/船号为空");
			}
			//是否过境
			if (paraMap.get("transit")!=null) {
				Short transit = Short.parseShort(paraMap.get("transit").toString());
				thailandTravInfo.setTransit(transit);
			}
			//居住方式
			if (paraMap.get("residentialmode")!=null) {
				String residentialmode = paraMap.get("residentialmode").toString();
				thailandTravInfo.setResidentialmode(residentialmode);
			}
			//居住府
			if (paraMap.get("stateofresidence")!=null) {
				String stateofresidence = paraMap.get("stateofresidence").toString();
				thailandTravInfo.setStateofresidence(stateofresidence);
			}
			//居住府
			if (paraMap.get("specificaddress")!=null) {
				String specificaddress = paraMap.get("specificaddress").toString();
				thailandTravInfo.setSpecificaddress(specificaddress);
			}
			//离境日期
			if (paraMap.get("dateofleave")!=null) {
				String dateofleaveString = paraMap.get("dateofleave").toString();
				Date dateofleave = new SimpleDateFormat("dd/MM/yyyy").parse(dateofleaveString);
				thailandTravInfo.setDateofleave(dateofleave);
			}
			//离境方式 航班号
			if (paraMap.get("leaveMethod")!=null && paraMap.get("leaveflightNo")!=null) {
				String leaveMethod = paraMap.get("leaveMethod").toString();
				String leaveflightNo = paraMap.get("leaveflightNo").toString();
				thailandTravInfo.setLeaveMethod(leaveMethod);
				thailandTravInfo.setLeaveflightNo(leaveflightNo);
			}
			//邮箱 手机
			if (paraMap.get("email")!=null && paraMap.get("mobile")!=null) {
				String email = paraMap.get("email").toString();
				String mobile = paraMap.get("mobile").toString();
				thailandTravInfo.setEmail(email);
				thailandTravInfo.setMobile(mobile);
			}else {
				throw  new Exception("邮箱或手机号为空");
			}
			//价格标准
			if (paraMap.get("ecpid")!=null) {
				String ecpid = paraMap.get("ecpid").toString();
				thailandTravInfo.setEcpid(ecpid);
			}else {
				throw  new Exception("价格标准为空");
			}	
			thailandTravInfo.setTitid(id);
			thailandTravInfo.setPubts(new Date());
			thailanTravInfoMapper.insert(thailandTravInfo);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return thailandTravInfo;
	}
	
	
	@Override
	public Malaysiatravinfo createMalaysiatravinfo(JSONObject paraMap,String id,Integer row) {
		// TODO Auto-generated method stub
		logger.error("马来西亚旅行信息"+JSON.toJSONString(paraMap));
		Malaysiatravinfo malaysiatravinfo = new Malaysiatravinfo();
		try {
			String iid = StringUtil.getId();
			malaysiatravinfo.setId(iid);
			malaysiatravinfo.setTrow(row);
			//获取参数
			//入境日期
			if (paraMap.get("dateofentry")!=null) {
				String dateofentryString = paraMap.get("dateofentry").toString();
				Date dateofentry = new SimpleDateFormat("dd/MM/yyyy").parse(dateofentryString);
				malaysiatravinfo.setDateofentry(dateofentry);
			}else {
				throw  new Exception("入境日期为空");
			}
			//离境日期
			if (paraMap.get("dateofleave")!=null) {
				String dateofleaveString = paraMap.get("dateofleave").toString();
				Date dateofleave = new SimpleDateFormat("dd/MM/yyyy").parse(dateofleaveString);
				malaysiatravinfo.setDateofleave(dateofleave);
			}else {
				throw  new Exception("离境日期为空");
			}
			//经停的国家
			if (paraMap.get("countryofstay")!=null) {
				String countryofstay = paraMap.get("countryofstay").toString();
				String countryofstayCn = paraMap.get("countryofstayCn").toString();
				malaysiatravinfo.setCountryofstay(countryofstay);
				malaysiatravinfo.setCountryofstayCn(countryofstayCn);
			}else {
				throw  new Exception("经停国家为空");
			}
			//入境方式 航班号
			if (paraMap.get("entrymethod")!=null && paraMap.get("flightno")!=null) {
				String entrymethod = paraMap.get("entrymethod").toString();
				String flightno = paraMap.get("flightno").toString();
				malaysiatravinfo.setEntrymethod(entrymethod);
				malaysiatravinfo.setFlightno(flightno);
			}else {
				throw  new Exception("入境方式或航班号/船号为空");
			}
			//州
			if (paraMap.get("stateofresidence")!=null && paraMap.get("stateofresidenceCn")!=null) {
				String stateofresidence = paraMap.get("stateofresidence").toString();
				String stateofresidenceCn = paraMap.get("stateofresidenceCn").toString();
				malaysiatravinfo.setStateofresidence(stateofresidence);
				malaysiatravinfo.setStateofresidenceCn(stateofresidenceCn);
			}else {
				throw  new Exception("到达州为空");
			}
			//城市
			if (paraMap.get("cityofresidence")!=null && paraMap.get("cityofresidenceCn")!=null) {
				String cityofresidence = paraMap.get("cityofresidence").toString();
				String cityofresidenceCn = paraMap.get("cityofresidenceCn").toString();
				malaysiatravinfo.setCityofresidence(cityofresidence);
				malaysiatravinfo.setCityofresidenceCn(cityofresidenceCn);
			}else {
				throw  new Exception("城市为空");
			}
			//居住方式或居住地址
			if (paraMap.get("residentialmode")!=null && paraMap.get("addressofstay")!=null) {
				String residentialmode = paraMap.get("residentialmode").toString();
				String addressofstay = paraMap.get("addressofstay").toString();
				malaysiatravinfo.setResidentialmode(residentialmode);
				malaysiatravinfo.setAddressofstay(addressofstay);
			}else {
				throw  new Exception("居住方式或居住地址为空");
			}
			//区号或手机号
			if (paraMap.get("region")!=null && paraMap.get("mobile")!=null) {
				String region = paraMap.get("region").toString();
				String mobile = paraMap.get("mobile").toString();
				malaysiatravinfo.setRegion(region);
				malaysiatravinfo.setMobile(mobile);
			}else {
				throw  new Exception("区号或手机号为空");
			}
			//邮编或邮箱
			if (paraMap.get("postcode")!=null && paraMap.get("email")!=null) {
				String postcode = paraMap.get("postcode").toString();
				String email = paraMap.get("email").toString();
				malaysiatravinfo.setPostcode(postcode);
				malaysiatravinfo.setEmail(email);
			}else {
				throw  new Exception("邮编或邮箱为空");
			}
			//价格标准
			if (paraMap.get("ecpid")!=null) {
				String ecpid = paraMap.get("ecpid").toString();
				malaysiatravinfo.setEcpid(ecpid);
			}else {
				throw  new Exception("价格标准为空");
			}	
			malaysiatravinfo.setTitid(id);
			malaysiatravinfo.setPubts(new Date());
			malaysiatravinfoMapper.insert(malaysiatravinfo);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			throw new RuntimeException(e.getMessage());
		}
		return malaysiatravinfo;
	}
	
	@Override
	public SingaporeTravInfo createSingaporeTravInfo(JSONObject paraMap,String id,Integer row) {
		// TODO Auto-generated method stub
		logger.error("新加坡旅行信息"+JSON.toJSONString(paraMap));
		SingaporeTravInfo singaporeTravIndo = new SingaporeTravInfo();
		try {
			String iid = StringUtil.getId();
			singaporeTravIndo.setId(iid);
			singaporeTravIndo.setTrow(row);
			//入境日期
			if (paraMap.get("dateofentry")!=null) {
				String dateofentryString = paraMap.get("dateofentry").toString();
				Date dateofentry = new SimpleDateFormat("dd/MM/yyyy").parse(dateofentryString);
				singaporeTravIndo.setDateofentry(dateofentry);
			}else {
				throw  new Exception("入境日期为空");
			}
			//离境日期
			if (paraMap.get("dateofleave")!=null) {
				String dateofleaveString = paraMap.get("dateofleave").toString();
				Date dateofleave = new SimpleDateFormat("dd/MM/yyyy").parse(dateofleaveString);
				singaporeTravIndo.setDateofleave(dateofleave);
			}else {
				throw  new Exception("离境日期为空");
			}
			//之前的城市和离去的城市
			if (paraMap.get("cityofBeforeEntry")!=null && paraMap.get("cityofAfterLeave")!=null) {
				String cityofBeforeEntry = paraMap.get("cityofBeforeEntry").toString();
				String cityofAfterLeave = paraMap.get("cityofAfterLeave").toString();
				singaporeTravIndo.setCityofBeforeEntry(cityofBeforeEntry);
				singaporeTravIndo.setCityofAfterLeave(cityofAfterLeave);
			}else {
				throw  new Exception("之前的城市和离去的城市为空");
			}
			//入境方式 航班号 航空公司
			if (paraMap.get("entrymethod")!=null && paraMap.get("flightno")!=null && paraMap.get("airlineCompany")!=null) {
				String entrymethod = paraMap.get("entrymethod").toString();
				String flightno = paraMap.get("flightno").toString();
				String airlineCompany = paraMap.get("airlineCompany").toString();
				singaporeTravIndo.setEntrymethod(entrymethod);
				singaporeTravIndo.setFlightno(flightno);
				singaporeTravIndo.setAirlineCompany(airlineCompany);
			}else {
				throw  new Exception("入境方式或航班号/船号为空");
			}
			//区号或手机号
			if (paraMap.get("region")!=null && paraMap.get("mobile")!=null) {
				String region = paraMap.get("region").toString();
				String mobile = paraMap.get("mobile").toString();
				singaporeTravIndo.setRegion(region);
				singaporeTravIndo.setMobile(mobile);
			}else {
				throw  new Exception("区号或手机号为空");
			}
			//居住方式或居住地址
			if (paraMap.get("residentialmode")!=null && paraMap.get("addressofstay")!=null) {
				String residentialmode = paraMap.get("residentialmode").toString();
				String addressofstay = paraMap.get("addressofstay").toString();
				singaporeTravIndo.setResidentialmode(residentialmode);
				singaporeTravIndo.setAddressofstay(addressofstay);
			}else {
				throw  new Exception("居住方式或居住地址为空");
			}
			//旅行目的或常居地
			if (paraMap.get("placeOfResidence")!=null && paraMap.get("purposeoftravel")!=null) {
				String placeOfResidence = paraMap.get("placeOfResidence").toString();
				String purposeoftravel = paraMap.get("purposeoftravel").toString();
				singaporeTravIndo.setPlaceOfResidence(placeOfResidence);
				singaporeTravIndo.setPurposeoftravel(purposeoftravel);
			}else {
				throw  new Exception("旅行目的或常居地为空");
			}
			//身体是否ok
			if (paraMap.get("toAfrica")!=null && paraMap.get("feelingokay")!=null && paraMap.get("useOtherPassport")!=null) {
				String toAfrica = paraMap.get("toAfrica").toString();
				String feelingokay = paraMap.get("feelingokay").toString();
				String useOtherPassport = paraMap.get("useOtherPassport").toString();
				singaporeTravIndo.setToAfrica(toAfrica);
				singaporeTravIndo.setFeelingokay(feelingokay);
				singaporeTravIndo.setUseOtherPassport(useOtherPassport);
			}else {
				throw  new Exception("身体是否ok为空");
			}
			//价格标准
			if (paraMap.get("ecpid")!=null) {
				String ecpid = paraMap.get("ecpid").toString();
				singaporeTravIndo.setEcpid(ecpid);
			}else {
				throw  new Exception("价格标准为空");
			}
			//邮箱
			if (paraMap.get("email")!=null && paraMap.get("useOtherPassport")!=null ) {
				String email = paraMap.get("email").toString();
				String useOtherPassport = paraMap.get("useOtherPassport").toString();
				singaporeTravIndo.setEmail(email);
				singaporeTravIndo.setUseOtherPassport(useOtherPassport);
			}else {
				throw  new Exception("价格标准为空");
			}
			singaporeTravIndo.setTitid(id);
			singaporeTravIndo.setPubts(new Date());
			singaporeTravIndoMapper.insert(singaporeTravIndo);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			throw new RuntimeException(e.getMessage());
		}
		return singaporeTravIndo;
	}
	
	@Override
	public Leadercode createLeadCodeInfo(String tlId, String countryCode) {
		// TODO Auto-generated method stub
		Integer count = leadercodeMapper.selectCount(new QueryWrapper<Leadercode>().eq("tl_code_status", 1));
		String code = StringUtil.genefourCode(count);
		//首先生成四位吗数据
		Leadercode leadercode = new Leadercode();
		String lcidString = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
		leadercode.setId(lcidString);
		leadercode.setTlCode(code);
		leadercode.setTlid(tlId);
		leadercode.setTlCountryCode(countryCode);
		leadercode.setTlCodeStatus(Short.parseShort("1"));
		leadercode.setPubts(new Date());
		leadercodeMapper.insert(leadercode);
		return leadercode;
	}
	
	@Override
	public LeaderInfo createLeaderInfo(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		LeaderInfo leaderInfo = new LeaderInfo();
		try {
			String id = StringUtil.getId();
			leaderInfo.setId(id);
			//获取领队信息
			if (paraMap.get("tlName")!=null && StringUtils.isNotEmpty(paraMap.get("tlName").toString())) {
				String tlName = paraMap.get("tlName").toString();
				leaderInfo.setTlName(tlName);
			}else {
				throw new Exception("领队姓名为空");
			}
			//获取微信信息
			if (paraMap.get("tlCode")!=null && StringUtils.isNotEmpty(paraMap.get("tlCode").toString())) {
				String tlCode = paraMap.get("tlCode").toString();
				leaderInfo.setTlCode(tlCode);
			}else {
				throw new Exception("领队微信为空");
			}
			//获取微信信息
			if (paraMap.get("tlWechat")!=null) {
				String tlWechat = paraMap.get("tlWechat").toString();
				leaderInfo.setTlWechat(tlWechat);
			}else {
				leaderInfo.setTlWechat(null);
			}
			//获取微信信息
			if (paraMap.get("tlMobile")!=null) {
				String tlMobile = paraMap.get("tlMobile").toString();
				leaderInfo.setTlMobile(tlMobile);
			}else {
				leaderInfo.setTlWechat(null);
			}
			//获取身份证信息
			if (paraMap.get("tlIdCard")!=null) {
				String tlIdCard = paraMap.get("tlIdCard").toString();
				leaderInfo.setTlIdCard(tlIdCard);
			}else {
				leaderInfo.setTlIdCard(null);
			}
			//获取身份证信息
			if (paraMap.get("tlBankCard")!=null) {
				String tlBankCard = paraMap.get("tlBankCard").toString();
				leaderInfo.setTlBankCard(tlBankCard);
			}else {
				leaderInfo.setTlBankCard(null);
			}
			
			if (paraMap.get("tlBankName")!=null) {
				String tlBankName = paraMap.get("tlBankName").toString();
				leaderInfo.setTlBankName(tlBankName);
			}else {
				leaderInfo.setTlBankName(null);
			}
			
			if (paraMap.get("tlTravelAgency")!=null) {
				String tlTravelAgency = paraMap.get("tlTravelAgency").toString();
				leaderInfo.setTlTravelAgency(tlTravelAgency);
			}else {
				leaderInfo.setTlTravelAgency(null);
			}
			if (paraMap.get("lgId")!=null) {
				String lgId = paraMap.get("lgId").toString();
				leaderInfo.setLgId(lgId);
			}else {
				leaderInfo.setLgId(null);
			}
			leaderInfo.setPubts(new Date());
			leaderInfoMapper.insert(leaderInfo);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			throw new RuntimeException(e.getMessage());
		}
		return leaderInfo;
	}
	
	@Override
	public Map<String, Object> addTraInfocode(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			if (paraMap.containsKey("gu_passport_num") && paraMap.containsKey("country")) {
				String gu_passport_num = "";
				//订单id
				if (paraMap.get("gu_passport_num")!=null) {
					gu_passport_num = paraMap.get("gu_passport_num").toString();
				}else {
					throw new Exception("护照号为空");
				}
				Integer row = 0;
				//订单id
				if (paraMap.get("trow")!=null) {
					row = Integer.parseInt(paraMap.get("trow").toString());
				}else {
					throw new Exception("行号为空");
				}
				String country = "";
				//订单id
				if (paraMap.get("country")!=null) {
					country = paraMap.get("country").toString();
				}else {
					throw new Exception("国家");
				}
				//获取护照信息
				List<PassportInfo> passInfoList = passportInfoMapper.selectList(new QueryWrapper<PassportInfo>().eq("gu_passport_num",gu_passport_num));
				for (int ik = 0; ik < passInfoList.size(); ik++) {
					PassportInfo passInfo = passInfoList.get(ik);
					
					if (Objects.nonNull(passInfo)) {
						String guId = passInfo.getId();
						if (paraMap.get("tlCode")!=null) {
							String tlCode = paraMap.get("tlCode").toString();
							Leadercode leaderCodeInfo = leadercodeMapper.selectOne(new QueryWrapper<Leadercode>().eq("tl_code", tlCode).eq("tl_code_status", 1));
							if (Objects.nonNull(leaderCodeInfo)) {
								String id2 = leaderCodeInfo.getId();
								Travelitinerary travelitinerary = travelitineraryMapper.selectOne(new QueryWrapper<Travelitinerary>().eq("tlid", id2));
								if (travelitinerary!=null) {
									String traveid = travelitinerary.getId();
									List<Ordertravpassport> ordertravpassportList = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("ecppid", guId).eq("travid", traveid));
									if (CollectionUtils.isNotEmpty(ordertravpassportList)) {
										for (int i = 0; i < ordertravpassportList.size(); i++) {
											Ordertravpassport ordertravpassport = ordertravpassportList.get(i);
											if (ordertravpassport!=null) {
												String orderid = ordertravpassport.getOrderid();
												if (Objects.nonNull(orderid)) {
													OrderInfo orderInfo = orderInfoMapper.selectById(orderid);
													if (Objects.nonNull(orderInfo)) {
														short ecPayStatus = orderInfo.getEcPayStatus();
														if (Objects.equals(ecPayStatus, Short.parseShort("1"))) {
															//获取国家码
															String[] titCodeArr = travelitinerary.getTitCode().split("-");
															if (titCodeArr.length<row) {
																throw new Exception("输入的行程不存在");
															}else {
																String titccode = titCodeArr[row-1];
																if (Objects.equals(titccode, country)) {
																	TravelCodeRelation travelCodeRelation = travelCodeRelationMapper.selectOne(new QueryWrapper<TravelCodeRelation>().eq("otpid", traveid).eq("trow", row));
																	if (Objects.nonNull(travelCodeRelation)) {
																		String tcid = travelCodeRelation.getTcid();
																		//获取pin码
																		TravInfoCode travInfoCode = travinfoCodeMapper.selectById(tcid);
																		if (Objects.nonNull(travInfoCode)) {
																			String code = paraMap.get("pinCode").toString();
																			travInfoCode.setCode(code);
																			resultMap.put("travInfoCode", travInfoCode);
																			travinfoCodeMapper.updateById(travInfoCode);
																		}
																	}else {
																		//识别码
																		if (paraMap.get("pinCode")!=null) {
																			TravInfoCode travInfoCode = new TravInfoCode();
																			String code = paraMap.get("pinCode").toString();
																			
																			String id = StringUtil.getId();
																			travInfoCode.setId(id);
																			travInfoCode.setCode(code);
																			travInfoCode.setPubts(new Date());
																			travinfoCodeMapper.insert(travInfoCode);
																			resultMap.put("travInfoCode", travInfoCode);
																			TravelCodeRelation travelCodeRelation2 = new TravelCodeRelation();
																			travelCodeRelation2.setId(StringUtil.getId());
																			travelCodeRelation2.setOtpid(ordertravpassport.getId());
																			travelCodeRelation2.setTrow(row);
																			travelCodeRelation2.setTcid(id);
																			travelCodeRelation2.setPubts(new Date());
																			travelCodeRelationMapper.insert(travelCodeRelation2);
																		}else {
																			throw new Exception("pinCode为空");
																		}
																		
																	}
																}else {
																	throw new Exception("输入的行程和国家码不匹配");
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}else if (paraMap.containsKey("pinCodeArr")) {
				JSONArray parseArray = JSONArray.parseArray(JSON.toJSONString(paraMap.get("pinCodeArr")));
				for (int a = 0; a < parseArray.size(); a++) {
					JSONObject jsonObject = parseArray.getJSONObject(a);
					
					String guId = jsonObject.getString("guId");
					String stId = jsonObject.getString("stId");
					//获取护照信息
					PassportInfo passportInfo = passportInfoMapper.selectById(guId);
					if (Objects.nonNull(passportInfo)) {
						String ecppid = passportInfo.getId();
						//获取旅行信息
						String titid = "";
						Integer trow = 99;
						SingaporeTravInfo singaporeTravInfo = singaporeTravIndoMapper.selectById(stId);
						if (Objects.nonNull(singaporeTravInfo)) {
							titid = singaporeTravInfo.getTitid();
							trow = singaporeTravInfo.getTrow();
						}else  {
							Malaysiatravinfo malaysiatravinfo = malaysiatravinfoMapper.selectById(stId);
							if (Objects.nonNull(malaysiatravinfo)) {
								titid = malaysiatravinfo.getTitid();
								trow = malaysiatravinfo.getTrow();
							}else {
								ThailandTravInfo thailandTravInfo = thailanTravInfoMapper.selectById(stId);
								if (Objects.nonNull(thailandTravInfo)) {
									titid = thailandTravInfo.getTitid();
									trow = thailandTravInfo.getTrow();
								}
							}
						}
						if (StringUtils.isNotBlank(titid) && trow!=99) {
							//获取形成关系表
							QueryWrapper<Ordertravpassport> queryWrapperOrdertravpassport = new QueryWrapper<>();
							queryWrapperOrdertravpassport.eq("ecppid", ecppid).eq("travid", titid);
							List<Ordertravpassport> ordertravpassports = ordertravpassportMapper.selectList(queryWrapperOrdertravpassport);
							for (int i = 0; i < ordertravpassports.size(); i++) {
								Ordertravpassport ordertravpassport = ordertravpassports.get(i);
								if (Objects.nonNull(ordertravpassport)) {
									String otpid = ordertravpassport.getId();
									//获取pin码关系表
									if (jsonObject.containsKey("pinCode")) {
										String code = jsonObject.getString("pinCode");
										List<TravelCodeRelation> travelCodeRelations = travelCodeRelationMapper.selectList(new QueryWrapper<TravelCodeRelation>().eq("otpid", otpid).eq("trow", trow));
										if (CollectionUtils.isNotEmpty(travelCodeRelations)) {
											for (int j = 0; j < travelCodeRelations.size(); j++) {
												TravelCodeRelation travelCodeRelation = travelCodeRelations.get(j);
											//获取输入的字段
												if (Objects.nonNull(travelCodeRelation.getTcid())) {
													String tcid = travelCodeRelation.getTcid();

													TravInfoCode travInfoCode = travinfoCodeMapper.selectById(tcid);
													if (Objects.nonNull(travInfoCode)) {
														travInfoCode.setCode(code);
														travinfoCodeMapper.updateById(travInfoCode);
														resultMap.put("travInfoCode", travInfoCode);
													}
												}
											}
										}else {
											TravInfoCode travInfoCode = new TravInfoCode();
											String id = StringUtil.getId();
											travInfoCode.setId(id);
											travInfoCode.setCode(code);
											travInfoCode.setPubts(new Date());
											travinfoCodeMapper.insert(travInfoCode);
											resultMap.put("travInfoCode", travInfoCode);
											TravelCodeRelation travelCodeRelation2 = new TravelCodeRelation();
											travelCodeRelation2.setId(StringUtil.getId());
											travelCodeRelation2.setOtpid(otpid);
											travelCodeRelation2.setTrow(trow);
											travelCodeRelation2.setTcid(id);
											travelCodeRelation2.setPubts(new Date());
											travelCodeRelationMapper.insert(travelCodeRelation2);
										}
									}else {
										throw  new Exception("缺少关键字段code");
									}
								}
							}
						}
					}
				}
			}

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			throw new RuntimeException(e.getMessage());
		}
		return resultMap;
	}
	
	@Override
	public void loopAcquisitionMailContent(Integer total) {
		// TODO Auto-generated method stub
		//获取邮箱信息
		List<MailInfo> mailInfoList = mailInfoMapper.selectList(new QueryWrapper<MailInfo>().eq("email_status", 2));
		Collections.shuffle(mailInfoList);
		MailInfo mailInfo = mailInfoList.get(0);
		List<Map<String, Object>> readUnreadMailsContent = mailUtil.readUnreadMailsContent(mailInfo,total);
		for (int i = 0; i < readUnreadMailsContent.size(); i++) {
			Map<String, Object> map = readUnreadMailsContent.get(i);
			String arrDate = map.get("arrDate").toString();
			String guPassportNum = map.get("guPassportNum").toString();
			logger.error("写入:"+guPassportNum+"-"+arrDate);
			PassportInfo passportInfo = passportInfoMapper.selectOne(new QueryWrapper<PassportInfo>().eq("gu_passport_num", guPassportNum));
			if (Objects.nonNull(passportInfo)) {
				String id = passportInfo.getId();
				List<Ordertravpassport> ordertavelInfo = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("ecppid", id).orderByDesc("pubts"));
				if (CollectionUtils.isNotEmpty(ordertavelInfo)) {
					for (int j = 0; j < ordertavelInfo.size(); j++) {
						Ordertravpassport ordertravpassport = ordertavelInfo.get(j);
						String ordertravpassportid = ordertravpassport.getId();
						String travid = ordertravpassport.getTravid();
						Travelitinerary travelitinerary = travelitineraryMapper.selectById(travid);
						logger.error("写入travelitinerary:"+JSON.toJSONString(travelitinerary));
						if (travelitinerary!=null) {
							String id2 = travelitinerary.getId();
							String[] titCodeArr = travelitinerary.getTitCode().split("-");
							for (int k = 0; k < titCodeArr.length; k++) {
								String titCode = titCodeArr[k];
								if (Objects.equals(titCode, "0060")) {
									Malaysiatravinfo malaysiatravinfo = malaysiatravinfoMapper.selectOne(new QueryWrapper<Malaysiatravinfo>().eq("titid", id2).eq("trow", k+1));
									logger.error("写入malaysiatravinfo:"+JSON.toJSONString(malaysiatravinfo));
									if (Objects.nonNull(malaysiatravinfo)) {
										Date dateofentry = malaysiatravinfo.getDateofentry();
										String format = new SimpleDateFormat("dd/MM/yyyy").format(dateofentry);
										logger.error("写入dateofentry:"+format+"-"+arrDate);
										if (Objects.equals(arrDate, format)) {
											if (map.containsKey("pins") && Objects.nonNull(map.get("pins"))) {
												String pins = map.get("pins").toString();
												Integer row = malaysiatravinfo.getTrow();
												TravelCodeRelation travelCodeRelation = travelCodeRelationMapper.selectOne(new QueryWrapper<TravelCodeRelation>().eq("otpid", ordertravpassportid).eq("trow", row));
												logger.error("写入travelCodeRelation:"+travelCodeRelation==null?null:JSON.toJSONString(travelCodeRelation));
												if (Objects.isNull(travelCodeRelation)) {
													//创建pin码对象
													writeIdnumber(pins, null, ordertravpassportid, malaysiatravinfo, null,null);
												}else {
													String tcid = travelCodeRelation.getTcid();
													if (StringUtils.isNotEmpty(tcid)) {
														TravInfoCode travInfoCode = travinfoCodeMapper.selectById(tcid);
														if (Objects.nonNull(travInfoCode) && StringUtils.isEmpty(travInfoCode.getCode())) {
															travInfoCode.setCode(pins);
															travInfoCode.setPubts(new Date());
															travinfoCodeMapper.updateById(travInfoCode);
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}		
		}
	}
	@Autowired
	private MalaysiaMadcRegUtil malaysiaMadcRegUtil;
	
	@SuppressWarnings("unchecked")
	@Override
	public Map<String, Object> submitAgain(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
        try {
			//获取邮箱信息
			List<MailInfo> mailInfoList = mailInfoMapper.selectList(new QueryWrapper<MailInfo>().eq("email_status", 2));
	        // 打乱集合顺序
	        Collections.shuffle(mailInfoList);
	        MailInfo mailInfo = new MailInfo();
	        if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(mailInfoList)) {
				mailInfo = mailInfoList.get(0);
			}
    		if (paraMap.containsKey("trow") && paraMap.containsKey("passport")) {
    			//获取护照号
    			String row = paraMap.get("trow").toString();
    			String passport = paraMap.get("passport").toString();
        		//获取数据
        		PassportInfo passportInfo = passportInfoMapper.selectOne(new QueryWrapper<PassportInfo>().eq("gu_passport_num", passport));
        		if (Objects.nonNull(passportInfo)) {
        			String id = passportInfo.getId();
        			//获取
        			List<Ordertravpassport> ordertavelInfo = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("ecppid", id).orderByDesc("pubts"));
        			if (CollectionUtils.isNotEmpty(ordertavelInfo)) {
        				for (int i = 0; i < ordertavelInfo.size(); i++) {
        					Ordertravpassport ordertravpassport = ordertavelInfo.get(i);
        					
            				if (Objects.nonNull(ordertravpassport)) {
            					String travid = ordertravpassport.getTravid();
            					logger.error("护照信息："+JSON.toJSONString(passportInfo));
            					//获取行程id
            					Travelitinerary ttTravelitinerary = travelitineraryMapper.selectById(travid);
            					if (Objects.nonNull(ttTravelitinerary)) {
            						String trid = ttTravelitinerary.getId();
            						String[] titCodeArr = ttTravelitinerary.getTitCode().split("-");
            						if (titCodeArr.length>=Integer.parseInt(row)) {
    									String titCode = titCodeArr[Integer.parseInt(row)-1];
    									if (Objects.equals(titCode, "0060")) {
    										Malaysiatravinfo malaTravInfo = malaysiatravinfoMapper.selectOne(new QueryWrapper<Malaysiatravinfo>().eq("titid", trid).eq("trow", row));
    										if (malaTravInfo!=null) {
    											Map<String, Object> hashMap = new HashMap<>();
    											Map<String, Object> convertMalaysiaSubmitInfo = convertPassportSubmitInfo(passportInfo,"0060");
    											Map<String, Object> convertMalaysiaTravelSubmitInfo = convertMalaysiaTravelSubmitInfo(malaTravInfo);
    											if (Objects.nonNull(convertMalaysiaSubmitInfo) && Objects.nonNull(convertMalaysiaTravelSubmitInfo)) {
    												
    												hashMap.put("mdacVisaCountry","ALL");
    												hashMap.put("submitRegistration","Submit");
    												hashMap.put("email",mailInfo.getEmailLogin());
    												hashMap.put("confirmEmail",mailInfo.getEmailLogin());
    												
    												
    												hashMap.putAll(convertMalaysiaSubmitInfo);
    												hashMap.putAll(convertMalaysiaTravelSubmitInfo);
    				            			        logger.error("----------------发起请求:"+JSON.toJSONString(hashMap)+"------------------------");
    				            					boolean register = malaysiaMadcRegUtil.register(hashMap);
    				            					logger.error("请求成功："+register);
    											}
    										}else {
    											throw new Exception("未获取到该行程信息");
    										}
    									}
    								}else {
    									throw new Exception("未获取到该行程信息");
    								}
    							}
            				}
    					}
        			}
        		}
			}else if(paraMap.containsKey("guid") && paraMap.containsKey("smId")){
				//获取信息
    			String guid = paraMap.get("guid").toString();
    			String smId = paraMap.get("smId").toString();
				PassportInfo passportInfo = passportInfoMapper.selectById(guid);
				if (Objects.nonNull(passportInfo)) {
					Malaysiatravinfo malaysiatravinfo = malaysiatravinfoMapper.selectById(smId);
					if (Objects.nonNull(malaysiatravinfo)) {
						Map<String, Object> hashMap = new HashMap<>();
						Map<String, Object> convertMalaysiaSubmitInfo = convertPassportSubmitInfo(passportInfo,"0060");
						Map<String, Object> convertMalaysiaTravelSubmitInfo = convertMalaysiaTravelSubmitInfo(malaysiatravinfo);
						if (Objects.nonNull(convertMalaysiaSubmitInfo) && Objects.nonNull(convertMalaysiaTravelSubmitInfo)) {
							
							hashMap.put("mdacVisaCountry","ALL");
							hashMap.put("submitRegistration","Submit");
							hashMap.put("email",mailInfo.getEmailLogin());
							hashMap.put("confirmEmail",mailInfo.getEmailLogin());
							
							hashMap.putAll(convertMalaysiaSubmitInfo);
							hashMap.putAll(convertMalaysiaTravelSubmitInfo);
        			        logger.error("----------------发起请求:"+JSON.toJSONString(hashMap)+"------------------------");
        					boolean register = malaysiaMadcRegUtil.register(hashMap);
        					logger.error("请求成功："+register);
						}
					}else {
						SingaporeTravInfo singaporeTravInfo = singaporeTravIndoMapper.selectById(smId);
						if (Objects.nonNull(singaporeTravInfo)) {
							
						}
					}
				}
			}

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			throw new RuntimeException(e.getMessage());
		}

		return null;
	}
	
	
	@SuppressWarnings("unchecked")
	@Override
	public Map<String, Object> getPassportInfoByGroupCode(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		Map<String, Object> hashMap = new HashMap<>();
		try {
			List<Object> linkedList = new LinkedList<>();
			//获取四位团组码
			if (Objects.nonNull(paraMap) && Objects.nonNull(paraMap.get("groupCode")) && paraMap.get("groupCode").toString().length()==4) {
				String groupCode = paraMap.get("groupCode").toString();
				//获取
				Leadercode leadercode = leadercodeMapper.selectOne(new QueryWrapper<Leadercode>().eq("tl_code", groupCode).eq("tl_code_status", 1));
				if (Objects.nonNull(leadercode)) {
					String id = leadercode.getId();
					//和獲取行程信息
					Travelitinerary travelitinerary = travelitineraryMapper.selectOne(new QueryWrapper<Travelitinerary>().eq("tlid", id));
					if (Objects.nonNull(travelitinerary)) {
						String id2 = travelitinerary.getId();
						List<Ordertravpassport> ordertravpassports = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("travid", id2));
						if (Objects.nonNull(ordertravpassports)) {
							for (int i = 0; i < ordertravpassports.size(); i++) {
								Ordertravpassport ordertravpassport = ordertravpassports.get(i);
								String orderid = ordertravpassport.getOrderid();
								OrderInfo selectById = orderInfoMapper.selectById(orderid);
								if (Objects.nonNull(selectById)) {
									short ecPayStatus = selectById.getEcPayStatus();
									if (Objects.equals(ecPayStatus, Short.parseShort("1"))) {
										String ecppid = ordertravpassport.getEcppid();
										PassportInfo selectById2 = passportInfoMapper.selectById(ecppid);
										if (Objects.nonNull(selectById2)) {
											linkedList.add(selectById2);
										}
									}
								}
							}
						}else {
							throw new Exception("未獲取到該團組碼對應的旅客信息");
						}
					}else {
						throw new Exception("未獲取到該團組碼對應的團組信息");
					}
				}else {
					throw new Exception("团组码有误，请重新输入");
				}
			}else if (Objects.nonNull(paraMap) && Objects.nonNull(paraMap.get("travid"))) {
				//获取列表类型
				Object payObject = paraMap.get("payStatus");
				Short payStatusshort = null;
				if (Objects.nonNull(payObject)) {
					payStatusshort = Short.parseShort(payObject.toString());
				}else {
					payStatusshort = (short)1;
				}
				String travid = paraMap.get("travid").toString();
				//获取旅行信息
				Travelitinerary travelitinerary = travelitineraryMapper.selectById(travid);
				if (Objects.nonNull(travelitinerary)) {
					String titid = travelitinerary.getId();
					Integer titNum = travelitinerary.getTitNum();
					//获取关系表信息
					List<Ordertravpassport> ordertravpassportList = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("travid", titid));
					if (CollectionUtils.isNotEmpty(ordertravpassportList)) {
						for (int i = 0; i < ordertravpassportList.size(); i++) {
							Ordertravpassport ordertravpassport = ordertravpassportList.get(i);
							String ecppid = ordertravpassport.getEcppid();
							PassportInfo passportInfo = passportInfoMapper.selectById(ecppid);
							if (Objects.nonNull(ordertravpassport)) {
								String orderid = ordertravpassport.getOrderid();
								if (StringUtils.isNotEmpty(orderid)) {
									OrderInfo selectById = orderInfoMapper.selectById(orderid);
									if (Objects.nonNull(selectById)) {
										short ecPayStatus = selectById.getEcPayStatus();
										if (Objects.equals(ecPayStatus, Short.parseShort("1")) && Objects.equals(payStatusshort, (short)1)) {
											//获取通讯码信息
											String otpid = ordertravpassport.getId();
											Map<String, Object> hashMap2 = new HashMap<>();
											Map<String,Object> passportInfoObject = JSONObject.parseObject(JSON.toJSONString(passportInfo),Map.class);
											if (Objects.nonNull(passportInfoObject)) {
												hashMap2.putAll(passportInfoObject);
											}
											for (int j = 1; j <= titNum; j++) {
												List<TravelCodeRelation> travelCodeRelationList = travelCodeRelationMapper.selectList(new QueryWrapper<TravelCodeRelation>().eq("otpid", otpid).eq("trow", j));
												if (Objects.nonNull(passportInfo) && CollectionUtils.isEmpty(travelCodeRelationList)) {
												}else if (CollectionUtils.isNotEmpty(travelCodeRelationList)) {
													TravelCodeRelation travelCodeRelation = travelCodeRelationList.get(0);
													if (Objects.nonNull(travelCodeRelation)) {
														String tcid = travelCodeRelation.getTcid();
														if (Objects.nonNull(tcid)) {
															TravInfoCode travInfoCode = travinfoCodeMapper.selectById(tcid);
															if (Objects.nonNull(travInfoCode)) {
																String code = travInfoCode.getCode();
																hashMap2.put("pinCode_"+j, code);
															}
														}
													}
												}
											}
											linkedList.add(hashMap2);
										}else if (!Objects.equals(ecPayStatus, (short)1) && Objects.equals(payStatusshort, (short)0)) {
											linkedList.add(passportInfo);
										}
									}
								}else {
									if (Objects.equals(payStatusshort, (short)0)) {
										linkedList.add(passportInfo);									
									}
								}

							}
						}
					}else {
						throw new Exception("该团组暂未查询到已经支付的用户");
					}

				}else {
					throw new Exception("行程信息id有误，请重新输入");
				}
			}else {
				throw new Exception("团组码有误，请重新输入");
			}
			int size = linkedList.size();
			hashMap.put("passSize", size);
			hashMap.put("passList", linkedList);
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return hashMap;
	}
	
	@Override
	public Map<String, Object> getTravelInfoByGroupCode(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		Map<String, Object> resulttMap = new HashMap<>();
		try {
			List<Object> linkedList = new LinkedList<>();
			//获取四位团组码
			if (Objects.nonNull(paraMap) && Objects.nonNull(paraMap.get("groupCode")) && paraMap.get("groupCode").toString().length()==4) {
				String groupCode = paraMap.get("groupCode").toString();
				//获取
				Leadercode leadercode = leadercodeMapper.selectOne(new QueryWrapper<Leadercode>().eq("tl_code", groupCode).eq("tl_code_status", 1));
				if (Objects.nonNull(leadercode)) {
					String id = leadercode.getId();
					//和獲取行程信息
					Travelitinerary travelitinerary = travelitineraryMapper.selectOne(new QueryWrapper<Travelitinerary>().eq("tlid", id));
					if (Objects.nonNull(travelitinerary)) {
						String id2 = travelitinerary.getId();
						String[] titCodeArr = travelitinerary.getTitCode().split("-");
						for (int i = 0; i < titCodeArr.length; i++) {
							String string = titCodeArr[i];
							if (Objects.equals("0060", string)) {
								List<Malaysiatravinfo> malaysiatravinfoList = malaysiatravinfoMapper.selectList(new QueryWrapper<Malaysiatravinfo>().eq("titid", id2).eq("trow", i+1));
								linkedList.addAll(malaysiatravinfoList);
							}else if (Objects.equals("0065", string)) {
								List<SingaporeTravInfo> malaysiatravinfoList = singaporeTravIndoMapper.selectList(new QueryWrapper<SingaporeTravInfo>().eq("titid", id2).eq("trow", i+1));
								linkedList.addAll(malaysiatravinfoList);
							}else if (Objects.equals("0066", string)) {
								List<ThailandTravInfo> malaysiatravinfoList = thailanTravInfoMapper.selectList(new QueryWrapper<ThailandTravInfo>().eq("titid", id2).eq("trow", i+1));
								linkedList.addAll(malaysiatravinfoList);
							}
						}
					}else {
						throw new Exception("未獲取到該團組碼對應的團組信息");
					}
				}else {
					throw new Exception("团组码有误，请重新输入");
				}
			}else {
				throw new Exception("团组码有误，请重新输入");
			}
			int travNum = linkedList.size();
			resulttMap.put("travnum", travNum);
			resulttMap.put("travInfo", linkedList);
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return resulttMap;
	}
	
	@Override
	public List<PassportInfo> updatePassportInfo(JSONArray jsonArray) {
		// TODO Auto-generated method stub
		PassportInfo passportInfo = new PassportInfo();
		List<PassportInfo> linkedList = new LinkedList<>();
		try {
			if (CollectionUtils.isNotEmpty(jsonArray)) {
				for (int i = 0; i < jsonArray.size(); i++) {
					JSONObject jsonObject = jsonArray.getJSONObject(i);
					if (jsonObject.containsKey("id")) {
						PassportInfo passportInfo2 = passportInfoMapper.selectById(jsonObject.getString("id"));
						if (Objects.nonNull(passportInfo2)) {
							passportInfo = JSONObject.parseObject(JSON.toJSONString(jsonObject), PassportInfo.class);
							passportInfoMapper.updateById(passportInfo);
							linkedList.add(passportInfo);
						}else {
							throw new Exception("id有誤，沒有獲取到id對應的護照信息");
						}
						
					}else {
						throw new Exception("沒有護照信息id 不能修改");
					}
				}
			}
			
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return linkedList;
	}
	
	@Override
	public Malaysiatravinfo updateMalaTravelInfo(Map<String, Object>paraMap) {
		// TODO Auto-generated method stub
		Malaysiatravinfo malaysiatravinfo = new Malaysiatravinfo();
		try {
			if (paraMap.containsKey("id") && Objects.nonNull(paraMap.get("id"))) {
				String id = paraMap.get("id").toString();
				Malaysiatravinfo malaysiatravinfo2 = malaysiatravinfoMapper.selectById(id);
				if (Objects.nonNull(malaysiatravinfo2)) {
					malaysiatravinfo = malaysiatravinfo2;
					

					//获取参数
					//入境日期
					if (paraMap.get("dateofentry")!=null) {
						String dateofentryString = paraMap.get("dateofentry").toString();
						Date dateofentry = new SimpleDateFormat("dd/MM/yyyy").parse(dateofentryString);
						malaysiatravinfo.setDateofentry(dateofentry);
					}
					//离境日期
					if (paraMap.get("dateofleave")!=null) {
						String dateofleaveString = paraMap.get("dateofleave").toString();
						Date dateofleave = new SimpleDateFormat("dd/MM/yyyy").parse(dateofleaveString);
						malaysiatravinfo.setDateofleave(dateofleave);
					}
					//经停的国家
					if (paraMap.get("countryofstay")!=null) {
						String countryofstay = paraMap.get("countryofstay").toString();
						String countryofstayCn = paraMap.get("countryofstayCn").toString();
						malaysiatravinfo.setCountryofstay(countryofstay);
						malaysiatravinfo.setCountryofstayCn(countryofstayCn);
					}
					//入境方式 航班号
					if (paraMap.get("entrymethod")!=null && paraMap.get("flightno")!=null) {
						String entrymethod = paraMap.get("entrymethod").toString();
						String flightno = paraMap.get("flightno").toString();
						malaysiatravinfo.setEntrymethod(entrymethod);
						malaysiatravinfo.setFlightno(flightno);
					}
					//州
					if (paraMap.get("stateofresidence")!=null && paraMap.get("stateofresidenceCn")!=null) {
						String stateofresidence = paraMap.get("stateofresidence").toString();
						String stateofresidenceCn = paraMap.get("stateofresidenceCn").toString();
						malaysiatravinfo.setStateofresidence(stateofresidence);
						malaysiatravinfo.setStateofresidenceCn(stateofresidenceCn);
					}
					//城市
					if (paraMap.get("cityofresidence")!=null && paraMap.get("cityofresidenceCn")!=null) {
						String cityofresidence = paraMap.get("cityofresidence").toString();
						String cityofresidenceCn = paraMap.get("cityofresidenceCn").toString();
						malaysiatravinfo.setCityofresidence(cityofresidence);
						malaysiatravinfo.setCityofresidenceCn(cityofresidenceCn);
					}
					//居住方式或居住地址
					if (paraMap.get("residentialmode")!=null && paraMap.get("addressofstay")!=null) {
						String residentialmode = paraMap.get("residentialmode").toString();
						String addressofstay = paraMap.get("addressofstay").toString();
						malaysiatravinfo.setResidentialmode(residentialmode);
						malaysiatravinfo.setAddressofstay(addressofstay);
					}
					//区号或手机号
					if (paraMap.get("region")!=null && paraMap.get("mobile")!=null) {
						String region = paraMap.get("region").toString();
						String mobile = paraMap.get("mobile").toString();
						malaysiatravinfo.setRegion(region);
						malaysiatravinfo.setMobile(mobile);
					}
					//邮编或邮箱
					if (paraMap.get("postcode")!=null && paraMap.get("email")!=null) {
						String postcode = paraMap.get("postcode").toString();
						String email = paraMap.get("email").toString();
						malaysiatravinfo.setPostcode(postcode);
						malaysiatravinfo.setEmail(email);
					}
					//价格标准
					if (paraMap.get("ecpid")!=null) {
						String ecpid = paraMap.get("ecpid").toString();
						malaysiatravinfo.setEcpid(ecpid);
					}
					//行程id
					String titid = null;
					if (paraMap.get("titid")!=null) {
						titid = paraMap.get("titid").toString();
						malaysiatravinfo.setTitid(titid);
					}else {
						titid = malaysiatravinfo.getTitid();
					}
					malaysiatravinfo.setPubts(new Date());
					malaysiatravinfoMapper.updateById(malaysiatravinfo);
					//重新计算价格
					if (StringUtils.isNotEmpty(titid)) {
						reCalculPrice(titid);						
					}
				}else {
					throw new Exception("行程信息id有誤 沒有獲取到形成信息");
				}
			}else {
				throw new Exception("行程信息id有誤 不能修改");
			}

		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return malaysiatravinfo;
	}
	
	@Override
	public SingaporeTravInfo updateSingTravelInfo(Map<String, Object>paraMap) {
		// TODO Auto-generated method stub
		SingaporeTravInfo singaporeTravIndo = new SingaporeTravInfo();
		try {
			if (paraMap.containsKey("id") && Objects.nonNull(paraMap.get("id"))) {
				String id = paraMap.get("id").toString();
				SingaporeTravInfo singaporeTravInfo2 = singaporeTravIndoMapper.selectById(id);
				if (Objects.nonNull(singaporeTravInfo2)) {
					singaporeTravIndo = singaporeTravInfo2;
					
					//入境日期
					if (paraMap.get("dateofentry")!=null) {
						String dateofentryString = paraMap.get("dateofentry").toString();
						Date dateofentry = new SimpleDateFormat("dd/MM/yyyy").parse(dateofentryString);
						singaporeTravIndo.setDateofentry(dateofentry);
					}
					//离境日期
					if (paraMap.get("dateofleave")!=null) {
						String dateofleaveString = paraMap.get("dateofleave").toString();
						Date dateofleave = new SimpleDateFormat("dd/MM/yyyy").parse(dateofleaveString);
						singaporeTravIndo.setDateofleave(dateofleave);
					}
					//之前的城市和离去的城市
					if (paraMap.get("cityofBeforeEntry")!=null && paraMap.get("cityofAfterLeave")!=null) {
						String cityofBeforeEntry = paraMap.get("cityofBeforeEntry").toString();
						String cityofAfterLeave = paraMap.get("cityofAfterLeave").toString();
						singaporeTravIndo.setCityofBeforeEntry(cityofBeforeEntry);
						singaporeTravIndo.setCityofAfterLeave(cityofAfterLeave);
					}
					//入境方式 航班号
					if (paraMap.get("entrymethod")!=null && paraMap.get("flightno")!=null) {
						String entrymethod = paraMap.get("entrymethod").toString();
						String flightno = paraMap.get("flightno").toString();
						singaporeTravIndo.setEntrymethod(entrymethod);
						singaporeTravIndo.setFlightno(flightno);
					}
					//区号或手机号
					if (paraMap.get("region")!=null && paraMap.get("mobile")!=null) {
						String region = paraMap.get("region").toString();
						String mobile = paraMap.get("mobile").toString();
						singaporeTravIndo.setRegion(region);
						singaporeTravIndo.setMobile(mobile);
					}
					//居住方式或居住地址
					if (paraMap.get("residentialmode")!=null && paraMap.get("addressofstay")!=null) {
						String residentialmode = paraMap.get("residentialmode").toString();
						String addressofstay = paraMap.get("addressofstay").toString();
						singaporeTravIndo.setResidentialmode(residentialmode);
						singaporeTravIndo.setAddressofstay(addressofstay);
					}
					//旅行目的或常居地
					if (paraMap.get("placeOfResidence")!=null && paraMap.get("purposeoftravel")!=null) {
						String placeOfResidence = paraMap.get("placeOfResidence").toString();
						String purposeoftravel = paraMap.get("purposeoftravel").toString();
						singaporeTravIndo.setPlaceOfResidence(placeOfResidence);
						singaporeTravIndo.setPurposeoftravel(purposeoftravel);
					}
					//身体是否ok
					if (paraMap.get("toAfrica")!=null && paraMap.get("feelingokay")!=null && paraMap.get("useOtherPassport")!=null) {
						String toAfrica = paraMap.get("toAfrica").toString();
						String feelingokay = paraMap.get("feelingokay").toString();
						String useOtherPassport = paraMap.get("useOtherPassport").toString();
						singaporeTravIndo.setToAfrica(toAfrica);
						singaporeTravIndo.setFeelingokay(feelingokay);
						singaporeTravIndo.setUseOtherPassport(useOtherPassport);
					}
					//价格标准
					if (paraMap.get("ecpid")!=null) {
						String ecpid = paraMap.get("ecpid").toString();
						singaporeTravIndo.setEcpid(ecpid);
					}
					//邮箱
					if (paraMap.get("email")!=null && paraMap.get("useOtherPassport")!=null ) {
						String email = paraMap.get("email").toString();
						String useOtherPassport = paraMap.get("useOtherPassport").toString();
						singaporeTravIndo.setEmail(email);
						singaporeTravIndo.setUseOtherPassport(useOtherPassport);
					}
					//行程id
					String titid = null;
					if (paraMap.get("titid")!=null) {
						titid = paraMap.get("titid").toString();
						singaporeTravIndo.setTitid(titid);
					}else {
						titid = singaporeTravIndo.getTitid();
					}
					singaporeTravIndo.setPubts(new Date());
					singaporeTravIndoMapper.updateById(singaporeTravIndo);
					//重新计算价格
					if (StringUtils.isNotEmpty(titid)) {
						reCalculPrice(titid);						
					}
				}else {
					throw new Exception("行程信息id有誤 沒有獲取到形成信息");
				}
			}else {
				throw new Exception("行程信息id有誤 不能修改");
			}

		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return singaporeTravIndo;
	}
	
	public ThailandTravInfo updateThailandTravInfo(Map<String, Object>paraMap) {
		logger.error("泰国旅行信息"+JSON.toJSONString(paraMap));
		ThailandTravInfo thailandTravInfo = new ThailandTravInfo();
		try {
			if (paraMap.containsKey("id") && Objects.nonNull(paraMap.get("id"))) {
				String id = paraMap.get("id").toString();
				ThailandTravInfo thailandTravInfo2 = thailanTravInfoMapper.selectById(id);
				if (Objects.nonNull(thailandTravInfo2)) {
					thailandTravInfo = thailandTravInfo2;
					
					//获取参数
					//入境日期
					if (paraMap.get("dateofentry")!=null) {
						String dateofentryString = paraMap.get("dateofentry").toString();
						Date dateofentry = new SimpleDateFormat("dd/MM/yyyy").parse(dateofentryString);
						thailandTravInfo.setDateofentry(dateofentry);
					}else {
						throw  new Exception("入境日期为空");
					}

					//居住地 旅行目的
					if (paraMap.get("purposeoftravel")!=null && paraMap.get("placeOfResidence")!=null) {
						String purposeoftravel = paraMap.get("purposeoftravel").toString();
						String placeOfResidence = paraMap.get("placeOfResidence").toString();
						thailandTravInfo.setPurposeoftravel(purposeoftravel);
						thailandTravInfo.setPlaceOfResidence(placeOfResidence);
					}else {
						throw  new Exception("居住地/旅行目的为空");
					}
					//出发国家，出发前滞留的国家
					if (paraMap.get("departureCountry")!=null && paraMap.get("stayBeforeEntryCountry")!=null) {
						String departureCountry = paraMap.get("departureCountry").toString();
						String stayBeforeEntryCountry = paraMap.get("stayBeforeEntryCountry").toString();
						thailandTravInfo.setDepartureCountry(departureCountry);
						thailandTravInfo.setStayBeforeEntryCountry(stayBeforeEntryCountry);
					}else {
						throw  new Exception("出发国家/出发前滞留国家为空");
					}
					//入境方式 航班号
					if (paraMap.get("entryMethod")!=null && paraMap.get("flightNo")!=null) {
						String entrymethod = paraMap.get("entryMethod").toString();
						String flightno = paraMap.get("flightNo").toString();
						thailandTravInfo.setEntryMethod(entrymethod);
						thailandTravInfo.setFlightNo(flightno);
					}else {
						throw  new Exception("入境方式或航班号/船号为空");
					}
					//是否过境
					if (paraMap.get("transit")!=null) {
						Short transit = Short.parseShort(paraMap.get("transit").toString());
						thailandTravInfo.setTransit(transit);
					}
					//居住方式
					if (paraMap.get("residentialmode")!=null) {
						String residentialmode = paraMap.get("residentialmode").toString();
						thailandTravInfo.setResidentialmode(residentialmode);
					}
					//居住府
					if (paraMap.get("stateofresidence")!=null) {
						String stateofresidence = paraMap.get("stateofresidence").toString();
						thailandTravInfo.setStateofresidence(stateofresidence);
					}
					//居住详细地址
					if (paraMap.get("specificaddress")!=null) {
						String specificaddress = paraMap.get("specificaddress").toString();
						thailandTravInfo.setSpecificaddress(specificaddress);
					}
					//离境日期
					if (paraMap.get("dateofleave")!=null) {
						String dateofleaveString = paraMap.get("dateofleave").toString();
						Date dateofleave = new SimpleDateFormat("dd/MM/yyyy").parse(dateofleaveString);
						thailandTravInfo.setDateofleave(dateofleave);
					}
					//离境方式 航班号
					if (paraMap.get("leaveMethod")!=null && paraMap.get("leaveflightNo")!=null) {
						String leaveMethod = paraMap.get("leaveMethod").toString();
						String leaveflightNo = paraMap.get("leaveflightNo").toString();
						thailandTravInfo.setLeaveMethod(leaveMethod);
						thailandTravInfo.setLeaveflightNo(leaveflightNo);
					}
					//邮箱 手机
					if (paraMap.get("email")!=null && paraMap.get("mobile")!=null) {
						String email = paraMap.get("email").toString();
						String mobile = paraMap.get("mobile").toString();
						thailandTravInfo.setEmail(email);
						thailandTravInfo.setMobile(mobile);
					}else {
						throw  new Exception("邮箱或手机号为空");
					}
					//价格标准
					if (paraMap.get("ecpid")!=null) {
						String ecpid = paraMap.get("ecpid").toString();
						thailandTravInfo.setEcpid(ecpid);
					}
					//行程id
					String titid = null;
					if (paraMap.get("titid")!=null) {
						titid = paraMap.get("titid").toString();
						thailandTravInfo.setTitid(titid);
					}else {
						titid = thailandTravInfo.getTitid();
					}
					thailandTravInfo.setPubts(new Date());
					thailanTravInfoMapper.updateById(thailandTravInfo);
					//重新计算价格
					if (StringUtils.isNotEmpty(titid)) {
						reCalculPrice(titid);						
					}
				}else {
					throw new Exception("行程信息id有誤 沒有獲取到形成信息");
				}
			}else {
				throw new Exception("行程信息id有誤 不能修改");
			}
			
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return thailandTravInfo;
	}
	
	@Override
	public void reCalculPrice(String titid) {
		// TODO Auto-generated method stub
		try {
			//重算形成总价格
			//先查询行程信息
			Travelitinerary travelitinerary = travelitineraryMapper.selectById(titid);
			if (Objects.nonNull(travelitinerary)) {
				String titCode = travelitinerary.getTitCode();
				//判断国家
				BigDecimal price = BigDecimal.ZERO;
				if (StringUtils.isNoneEmpty(titCode)) {
					String[] arr = titCode.split("-");
					for (int i = 0; i < arr.length; i++) {
						String country_code = arr[i];
						String ecpid = "";
						if (Objects.equals(country_code, "0060")) {
							Malaysiatravinfo selectOne = malaysiatravinfoMapper.selectOne(new QueryWrapper<Malaysiatravinfo>().eq("titid", titid).eq("trow", i+1));
							if (Objects.nonNull(selectOne)) {
								ecpid = selectOne.getEcpid();
							}
						}else if(Objects.equals(country_code, "0065")) {
							SingaporeTravInfo selectOne = singaporeTravIndoMapper.selectOne(new QueryWrapper<SingaporeTravInfo>().eq("titid", titid).eq("trow", i+1));
							if (Objects.nonNull(selectOne)) {
								ecpid = selectOne.getEcpid();
							}
						}else if(Objects.equals(country_code, "0066")) {
							ThailandTravInfo selectOne = thailanTravInfoMapper.selectOne(new QueryWrapper<ThailandTravInfo>().eq("titid", titid).eq("trow", i+1));
							if (Objects.nonNull(selectOne)) {
								ecpid = selectOne.getEcpid();
							}
						}
						if (StringUtils.isNotEmpty(ecpid)) {
							price = price.add(getTravelPriceInfo(ecpid));
							travelitinerary.setTitPrice(price);
							travelitineraryMapper.updateById(travelitinerary);
						}
					}
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
	}
	
	
	@Override
	public PageInfo<LeaderInfo> getLeaderInfoList(Map<String, Object>paraMap) {
		// TODO Auto-generated method stub
		PageInfo<LeaderInfo> leaderPage = new PageInfo<>();
		try {
			//获取页面信息
			if (paraMap.containsKey("pageIndex") && paraMap.containsKey("pageSize")) {
				//页码参数
				Integer pageSize = Integer.parseInt(paraMap.get("pageSize").toString());
				Integer pageIndex = Integer.parseInt(paraMap.get("pageIndex").toString());
				//获取关键
				QueryWrapper<LeaderInfo> queryWrapper = new QueryWrapper<LeaderInfo>();
				queryWrapper.orderByDesc("tl_code");
				if (paraMap.containsKey("word")) {
					String word = paraMap.get("word").toString();
					queryWrapper.like("tl_code", word).or().like("tl_name", word).or().like("tl_travel_agency", word);
				}
				PageHelper.startPage(pageIndex, pageSize, true);
				//获取领队信息列表
				List<LeaderInfo> selectList = leaderInfoMapper.selectList(queryWrapper);
				leaderPage = new PageInfo<>(selectList);
			}else {
				throw new Exception("页码参数错误");
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		return leaderPage;
	}
	
	@Override
	public List<EnumTravel> getEnumTravelList(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		try {
			if (paraMap.containsKey("countryCode") && paraMap.containsKey("enumtype")) {
				String enumtype = paraMap.get("enumtype").toString();
				String countryCode = paraMap.get("countryCode").toString();
				QueryWrapper<EnumTravel> queryWrapper = new QueryWrapper<EnumTravel>().eq("country_code", countryCode).eq("enumtype", enumtype);
				if (Objects.equals("0060", countryCode)) {
					if (Objects.equals(enumtype, "tc_country")) {
						queryWrapper.orderByDesc("enumcode in ('CHN','SGP')");
					}if (Objects.equals(enumtype, "tc_state")) {
						queryWrapper.orderByDesc("enumcode='14_50000'");
					}
				}else if (Objects.equals("0065", countryCode)) {
					if (Objects.equals(enumtype, "tc_country")) {
						queryWrapper.orderByDesc("enumcode in ('CHINA','SINGAPORE','MALAYSIA')");
					}else if (Objects.equals(enumtype, "tc_nationality")) {
						queryWrapper.orderByDesc("enumcode in ('CHINESE','MALAYSIAN')");
					}else if (Objects.equals(enumtype, "tc_country_city")) {
						queryWrapper.orderByDesc("enumcode like 'CHINA%'");
					}
				}
				List<EnumTravel> enumTravelList = enumTravelMapper.selectList(queryWrapper);
				//获取列表
				if (CollectionUtils.isNotEmpty(enumTravelList)) {
					return enumTravelList;
				}else {
					return new LinkedList<>();
				}
			}else {
				throw new Exception("缺少关键字段");
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
	}
	
	@Override
	public Map<String, Object> getRecentOrders(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		try {
			String guName = "";
			String tlTravelAgency = "";
			//获取用户id
			if (paraMap.containsKey("openId")) {
				String openId = paraMap.get("openId").toString();
				//获取用户id
				WxuserInfo wxuserInfo = wxuserInfoMapper.selectOne(new QueryWrapper<WxuserInfo>().eq("wxuser_id", openId));
				if (Objects.nonNull(wxuserInfo)) {
					String id = wxuserInfo.getId();
					//获取订单列表
					Calendar instance = Calendar.getInstance();
					instance.set(Calendar.DATE, -15);
					String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(instance.getTime());
					QueryWrapper<OrderInfo> queryWrapper = new QueryWrapper<>();
					queryWrapper.eq("user_id", id).gt("pubts", format);
					List<OrderInfo> selectList = orderInfoMapper.selectList(queryWrapper);
					if (CollectionUtils.isNotEmpty(selectList)) {
						OrderInfo orderInfo = selectList.get(0);
						if (Objects.nonNull(orderInfo)) {
							String orderId = orderInfo.getId();
							List<Ordertravpassport> ordertravpassports = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("orderid", orderId));
							if (CollectionUtils.isNotEmpty(ordertravpassports)) {
								Ordertravpassport ordertravpassport = ordertravpassports.get(0);
								if (Objects.nonNull(ordertravpassport)) {
									String ecppid = ordertravpassport.getEcppid();
									PassportInfo selectById = passportInfoMapper.selectById(ecppid);
									if (Objects.nonNull(selectById)) {
										guName = selectById.getGuName();
									}
									String travid = ordertravpassport.getTravid();
									Travelitinerary selectById2 = travelitineraryMapper.selectById(travid);
									if (Objects.nonNull(selectById2)) {
										String tlid = selectById2.getTlid();
										Leadercode selectById3 = leadercodeMapper.selectById(tlid);
										if (Objects.nonNull(selectById3)) {
											String tlid2 = selectById3.getTlid();
											LeaderInfo selectById4 = leaderInfoMapper.selectById(tlid2);
											if (Objects.nonNull(selectById4)) {
												tlTravelAgency = selectById4.getTlTravelAgency();
											}
										}
									}
								}
							}
						}
					}
					Map<String, Object> hashMap = new HashMap<>();
					hashMap.put("guName", guName);
					hashMap.put("tlTravelAgency", tlTravelAgency);
					return hashMap;
				}else {
					return new HashMap<>();
				}
			}else {
				throw new Exception("缺少openId字段");
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
	}
	
	@Override
	public Map<String, Object> loginInfo(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		Map<String, Object> hashMap = new HashMap<>();
		try {
			if (paraMap.containsKey("userName") && paraMap.containsKey("passWord")) {
				String userName = paraMap.get("userName").toString();
				List<LoginInfo> loginInfos = loginInfoMapper.selectList(new QueryWrapper<LoginInfo>().eq("user_name", userName));
				if (CollectionUtils.isNotEmpty(loginInfos)) {
					LoginInfo loginInfo = loginInfos.get(0);
					String passWordString = paraMap.get("passWord").toString();
					if (Objects.equals(passWordString, loginInfo.getPassWord())) {
						hashMap.put("id", loginInfo.getId());
						hashMap.put("userMobile", loginInfo.getMobile());
						hashMap.put("nickName", loginInfo.getNickName());
					}else {
						throw new Exception("密码错误，请重新输入");
					}
				}else {
					throw new Exception("查不到此用户信息");
				}
			}else {
				throw new Exception("缺少登录字段");
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return hashMap;
	}
	
	@Override
	public Map<String, Object> getCountryPriceInfo(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		Map<String, Object> resultMap = new HashMap<>();
		try {
			//获取国家吗
			if (paraMap.containsKey("countryCode")) {
				String countryCode = paraMap.get("countryCode").toString();
				//获取价格列表
				List<PriceInfo> priceinfoList = priceInfoMapper.selectList(new QueryWrapper<PriceInfo>().eq("ecp_country", countryCode));
				int priceinfoSize = priceinfoList.size();
				
				resultMap.put("priceInfoSize", priceinfoSize);
				resultMap.put("priceInfoList", priceinfoList);
			}else {
				throw new Exception("缺少国家码");
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return resultMap;
	}
	
	@Override
	public Map<String, Object> getTravelInfoList(Map<String, Object> paraMap) {
		// TODO Auto-generated method stub
		Map<String, Object> resultMap = new HashMap<>();
		try {
			if (paraMap.containsKey("lgId")) {
				if (paraMap.containsKey("pageIndex") && paraMap.containsKey("pageSize")) {
					String lgId = paraMap.get("lgId").toString();
					String pageIndex = paraMap.get("pageIndex").toString();
					String pageSize = paraMap.get("pageSize").toString();
					
					Integer pageIndexLong = Integer.parseInt(pageIndex);
					Integer pageSizeLong = Integer.parseInt(pageSize);
					//获取行程信息
					List<Map<String, Object>> linkedList = new LinkedList<>();
//					Page<Travelitinerary> page = new Page<Travelitinerary>(pageIndexLong, pageSizeLong);
//					logger.error("分页查询pageIndex："+pageIndex+",pageSize:"+pageSize);
					//创建条件
					QueryWrapper<Travelitinerary> travelitineraryQueryWrapper = new QueryWrapper<Travelitinerary>();
					travelitineraryQueryWrapper.eq("lg_id", lgId);
					travelitineraryQueryWrapper.orderByDesc("pubts");
					//获取其他模糊搜索信息
					Object object = paraMap.get("word");
					if (Objects.nonNull(object)) {
						String word = object.toString();
						//首先判断是不是领队信息
						QueryWrapper<LeaderInfo> leaderQueryWrapper = new QueryWrapper<>();
						leaderQueryWrapper.like("tl_name", word).or().like("tl_code", word);
						List<LeaderInfo> leaderInfos = leaderInfoMapper.selectList(leaderQueryWrapper);
						//获取领队id
						List<String> leaderIds = leaderInfos.stream().map(t->t.getId()).collect(Collectors.toList());
						//创建查询团组码条件
						QueryWrapper<Leadercode> leaderCodeQueryWrapper = new QueryWrapper<>();
						leaderCodeQueryWrapper.like("tl_code", word);
						if (CollectionUtils.isNotEmpty(leaderIds)) {
							leaderCodeQueryWrapper.or().in("tlid", leaderIds);
						}
						leaderCodeQueryWrapper.eq("tl_code_status", 1);
						List<Leadercode> leadercodes = leadercodeMapper.selectList(leaderCodeQueryWrapper);
						if (CollectionUtils.isNotEmpty(leadercodes)) {
							List<String> collect = leadercodes.stream().map(t->t.getId()).collect(Collectors.toList());
							travelitineraryQueryWrapper.in("tlid", collect);
						}
					}
//					logger.error("分页查询page："+JSON.toJSONString(page));
					PageHelper.startPage(pageIndexLong, pageSizeLong, true);
					List<Travelitinerary> selectList = travelitineraryMapper.selectList(travelitineraryQueryWrapper);
					PageInfo<Travelitinerary> pageInfo = new PageInfo<>(selectList);
//					logger.error("分页查询："+JSON.toJSONString(pageInfo));
					if (Objects.nonNull(pageInfo)) {
						List<Travelitinerary> travelitineraryList = pageInfo.getList();
//						List<Travelitinerary> travelitineraryList = selectPage.getRecords();
							Collections.sort(travelitineraryList,(t1,t2)->{
								return t2.getPubts().compareTo(t1.getPubts());
							});
						for (int i = 0; i < travelitineraryList.size(); i++) {
							Map<String, Object> hashMap = new HashMap<>();
							Travelitinerary travelitinerary = travelitineraryList.get(i);
							//获取
							String id = travelitinerary.getId();
							hashMap.put("id", id);
							String titName = travelitinerary.getTitName();
							hashMap.put("titName", titName);
							Integer titPernum = travelitinerary.getTitPernum();
							hashMap.put("titPernum", titPernum);
							String tlid = travelitinerary.getTlid();
							//获取团组吗
							Leadercode leadercode = leadercodeMapper.selectById(tlid);
							if (leadercode!=null) {
								String tlCode = leadercode.getTlCode();
								hashMap.put("tlCode", tlCode);
								String tlid2 = leadercode.getTlid();
								//获取领队姓名
								LeaderInfo leaderInfo = leaderInfoMapper.selectById(tlid2);
								if (leaderInfo!=null) {
									leaderInfo.setTlBankCard(null);
									leaderInfo.setTlBankName(null);
									leaderInfo.setTlIdCard(null);
									leaderInfo.setTlMobile(null);
									hashMap.put("leaderInfo", leaderInfo);
								}
							}
							//获取行程
							List<Object> linkedList2 = new LinkedList<>();
							String[] titCodeArr = travelitinerary.getTitCode().split("-");
							for (int j = 0; j < titCodeArr.length; j++) {
								String titCode = titCodeArr[j];
								Map<String, Object> hashMap2 = new HashMap<>();
								if (Objects.equals(titCode, "0060")) {
									Malaysiatravinfo malaysiatravinfo = malaysiatravinfoMapper.selectOne(new QueryWrapper<Malaysiatravinfo>().eq("titid", id).eq("trow", j+1));
									if (Objects.nonNull(malaysiatravinfo)) {
										Date dateofentry = malaysiatravinfo.getDateofentry();
										String format = new SimpleDateFormat("yyyy-MM-dd").format(dateofentry);
										Integer row = malaysiatravinfo.getTrow();
										hashMap2.put("trow", row);
										hashMap2.put("dateofentry", format);
										hashMap2.put("countryCode", "0060");
										hashMap2.put("stid", malaysiatravinfo.getId());
									}
								}else if (Objects.equals(titCode, "0065"))  {
									SingaporeTravInfo singaporeTravInfo = singaporeTravIndoMapper.selectOne(new QueryWrapper<SingaporeTravInfo>().eq("titid", id).eq("trow", j+1));
									if (Objects.nonNull(singaporeTravInfo)) {
										Date dateofentry = singaporeTravInfo.getDateofentry();
										String format = new SimpleDateFormat("yyyy-MM-dd").format(dateofentry);
										Integer row = singaporeTravInfo.getTrow();
										hashMap2.put("trow", row);
										hashMap2.put("dateofentry", format);
										hashMap2.put("countryCode", "0065");
										hashMap2.put("stid", singaporeTravInfo.getId());
									}
								}else if (Objects.equals(titCode, "0066")) {
									ThailandTravInfo thailandTravInfo = thailanTravInfoMapper.selectOne(new QueryWrapper<ThailandTravInfo>().eq("titid", id).eq("trow", j+1));
									if (Objects.nonNull(thailandTravInfo)) {
										Date dateofentry = thailandTravInfo.getDateofentry();
										String format = new SimpleDateFormat("yyyy-MM-dd").format(dateofentry);
										Integer row = thailandTravInfo.getTrow();
										hashMap2.put("trow", row);
										hashMap2.put("dateofentry", format);
										hashMap2.put("countryCode", "0066");
										hashMap2.put("stid", thailandTravInfo.getId());
									}
								}
								linkedList2.add(hashMap2);
							}
							hashMap.put("travelList", linkedList2);
							//获取人数
							List<Ordertravpassport> ordertravpassports = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("travid", id));
							if (ordertravpassports.size()==0) {
								hashMap.put("payPernum", 0);
							}else {
								Integer tInteger = 0;
								for (int j = 0; j < ordertravpassports.size(); j++) {
									Ordertravpassport ordertravpassport = ordertravpassports.get(j);
									String orderid = ordertravpassport.getOrderid();
									OrderInfo orderInfo = orderInfoMapper.selectById(orderid);
									if (orderInfo!=null) {
										short ecPayStatus = orderInfo.getEcPayStatus();
										if (Objects.equals(ecPayStatus, Short.parseShort("1"))) {
											tInteger += 1;
										}
									}
								}
								hashMap.put("payPernum", tInteger);
							}
							linkedList.add(hashMap);
						}
						int size = linkedList.size();
						resultMap.put("travSize", size);
						resultMap.put("travList", linkedList);
						resultMap.put("travCurrent", pageIndex);
						resultMap.put("travTotal", pageInfo.getTotal());
						resultMap.put("pageEndIndex", pageInfo.getEndRow());
						resultMap.put("pagePreIndex", pageInfo.getPrePage());
						resultMap.put("pageStartIndex", pageInfo.getStartRow());
						resultMap.put("pageIndex", pageInfo.getNavigatepageNums());
					}
				}
			}else {
				throw new Exception("缺少登录信息id码");
			}
		} catch (Exception e) {
			// TODO: handle exception
			logger.error(e);
			throw new RuntimeException(e.getMessage());
		}
		return resultMap;
	}
	
	@Override
	public void updateOrderInfoStatus(String orderId) {
		// TODO Auto-generated method stub
		try {
			OrderInfo orderInfo2 = new OrderInfo();
			String payTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS EEE").format(new Date());
			try {
				orderInfo2.setId(orderId);
				orderInfo2.setEcPayTime(payTime);
				orderInfo2.setEcStatus(Short.parseShort("1"));
				orderInfo2.setEcPayStatus(Short.parseShort("1"));
				orderInfo2.setEcPayTransactionId("000000000000");
				orderInfo2.setEcPayMethod("微信支付");
				// 修改支付状态
				orderInfoMapper.updateById(orderInfo2);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
	         // 开启线程
            ExecutorService cacheThreadPool = Executors.newCachedThreadPool();
            Callable<Boolean> clientAction = new Callable<Boolean>() {
                @Override
                public Boolean call() throws Exception {
                	wxuserService.afterPaySubmit(orderId);
                    return true;
                }
            };
            try {
                cacheThreadPool.submit(clientAction);
            } catch (Exception e) {
                logger.error("执行clientAction失败:" + e.getMessage(), e);
            } finally {
                cacheThreadPool.shutdown();
            }
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
	}
	
	@Override
	public void updateOrderStatusInfo() {
		// TODO Auto-generated method stub
		try {
			//获取一周之前的日期
			Calendar instance = Calendar.getInstance();
			instance.add(Calendar.DATE, -7);
			OrderInfo orderInfo = new OrderInfo();
			orderInfo.setEcStatus((short)0);
			QueryWrapper<OrderInfo> queryWrapper = new QueryWrapper<OrderInfo>();
			queryWrapper.lt("pubts", instance.getTime());
			orderInfoMapper.update(orderInfo, queryWrapper);
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Map<String, Object> submitInformationtoMalaysia(Map<String, Object> paramMap) {
		// TODO Auto-generated method stub\
		Map<String, Object> resultMap = new HashMap<>();
		try {
			List<Object> msgList = new LinkedList<>();
			//获取提交信息
			if (paramMap.containsKey("travid") && paramMap.containsKey("countryCode") && paramMap.containsKey("trow")) {
				String row = paramMap.get("trow").toString();
				String travid = paramMap.get("travid").toString();
				String countryCode = paramMap.get("countryCode").toString();
				Travelitinerary travelitinerary = travelitineraryMapper.selectById(travid);
				//获取邮箱信息
				List<MailInfo> mailInfoList = mailInfoMapper.selectList(new QueryWrapper<MailInfo>().eq("email_status", 2));
		        // 打乱集合顺序
		        Collections.shuffle(mailInfoList);
		        MailInfo mailInfo = new MailInfo();
		        if (CollectionUtils.isNotEmpty(mailInfoList)) {
					mailInfo = mailInfoList.get(0);
				}
				//获取旅行信息
				if (Objects.equals(countryCode, "0060")) {
					List<Map<String,Object>> submitList = new LinkedList<>();

					QueryWrapper<Malaysiatravinfo> queryWrapper = new QueryWrapper<>();
					queryWrapper.eq("titid", travid).eq("trow", row);
					List<Malaysiatravinfo> malaysiatravinfos = malaysiatravinfoMapper.selectList(queryWrapper);
					if (CollectionUtils.isNotEmpty(malaysiatravinfos)) {
						Malaysiatravinfo malaysiatravinfo = malaysiatravinfos.get(0);
						//获取支付信息
						QueryWrapper<Ordertravpassport> queryWrapper2 = new QueryWrapper<Ordertravpassport>();
						queryWrapper2.eq("travid", travid);
						List<Ordertravpassport> ordertravpassports = ordertravpassportMapper.selectList(queryWrapper2);
						if (CollectionUtils.isNotEmpty(ordertravpassports)) {
							for (int i = 0; i < ordertravpassports.size(); i++) {
								Ordertravpassport ordertravpassport = ordertravpassports.get(i);
								if (Objects.nonNull(ordertravpassport)) {
									String orderid = ordertravpassport.getOrderid();
									if (Objects.nonNull(orderid)) {
										OrderInfo orderInfo = orderInfoMapper.selectById(orderid);
										if (Objects.nonNull(orderInfo)) {
											short ecStatus = orderInfo.getEcStatus();
											short ecPayStatus = orderInfo.getEcPayStatus();
											if (Objects.equals(ecStatus, Short.parseShort("1")) && Objects.equals(ecPayStatus, Short.parseShort("1"))) {
												String ecppid = ordertravpassport.getEcppid();
												if (Objects.nonNull(ecppid)) {
													PassportInfo passportInfo = passportInfoMapper.selectById(ecppid);
													if (Objects.nonNull(passportInfo)) {
														Map<String, Object> hashMap = new HashMap<>();
														Map<String, Object> convertMalaysiaSubmitInfo = convertPassportSubmitInfo(passportInfo,"0060");
														Map<String, Object> convertMalaysiaTravelSubmitInfo = convertMalaysiaTravelSubmitInfo(malaysiatravinfo);
														if (Objects.nonNull(convertMalaysiaSubmitInfo) && Objects.nonNull(convertMalaysiaTravelSubmitInfo)) {
															resultMap.put("mdacVisaCountry","ALL");
															resultMap.put("submitRegistration","Submit");
															resultMap.put("email",mailInfo.getEmailLogin());
															resultMap.put("confirmEmail",mailInfo.getEmailLogin());
															
															hashMap.putAll(convertMalaysiaSubmitInfo);
															hashMap.putAll(convertMalaysiaTravelSubmitInfo);
															submitList.add(hashMap);
														}
													}
												}
											}else {
												msgList.add("id="+orderid+"的订单信息不符合提交的标准");
											}
										}else {
											msgList.add("未获取id="+orderid+"的订单信息");
										}
									}
								}
							}
						}else {
							msgList.add("未获取到该段行程的已支付成员的信息");
						}
						//获取乘客总数量
						Integer titPernum = travelitinerary.getTitPernum();
						int paySuccessnum = submitList.size();
						String subtip = "一共选择提交"+titPernum+"人,成功提交"+paySuccessnum+"人。";
						msgList.add(0, subtip);
						if (paySuccessnum==0) {
							throw new Exception("提交失败");
						}else {
				            // 开启线程
				            ExecutorService cacheThreadPool = Executors.newCachedThreadPool();
				            Callable<Boolean> clientAction = new Callable<Boolean>() {
				                @Override
				                public Boolean call() throws Exception {
				            		for (int i = 0; i < submitList.size(); i++) {
										Map<String, Object> submitMap = submitList.get(i);
										boolean register = malaysiaMadcRegUtil.register(submitMap);
										logger.error("执行成功："+register);
									}
				                    return true;
				                }
				            };
				            try {
				                cacheThreadPool.submit(clientAction);
				            } catch (Exception e) {
				                logger.error("执行clientAction失败:" + e.getMessage(), e);
				            } finally {
				                cacheThreadPool.shutdown();
				            }
						}
						resultMap.put("msgList", msgList);
						resultMap.put("subList", submitList);
						resultMap.put("titPernum", titPernum);
						resultMap.put("paySuccessnum", paySuccessnum);
					}else {
						msgList.add("未获取到该段行程信息");
					}
				}else if (Objects.equals(countryCode, "0065")) {
					
					List<Map<String,String>> submitList = new LinkedList<>();

					QueryWrapper<SingaporeTravInfo> queryWrapper = new QueryWrapper<>();
					queryWrapper.eq("titid", travid).eq("trow", row);
					List<SingaporeTravInfo> singaporeTravInfoList = singaporeTravIndoMapper.selectList(queryWrapper);
					if (CollectionUtils.isNotEmpty(singaporeTravInfoList)) {
						SingaporeTravInfo singaporeTravInfo = singaporeTravInfoList.get(0);
						//获取支付信息
						QueryWrapper<Ordertravpassport> queryWrapper2 = new QueryWrapper<Ordertravpassport>();
						queryWrapper2.eq("travid", travid);
						List<Ordertravpassport> ordertravpassports = ordertravpassportMapper.selectList(queryWrapper2);
						if (CollectionUtils.isNotEmpty(ordertravpassports)) {
							for (int i = 0; i < ordertravpassports.size(); i++) {
								Ordertravpassport ordertravpassport = ordertravpassports.get(i);
								if (Objects.nonNull(ordertravpassport)) {
									String orderid = ordertravpassport.getOrderid();
									if (Objects.nonNull(orderid)) {
										OrderInfo orderInfo = orderInfoMapper.selectById(orderid);
										if (Objects.nonNull(orderInfo)) {
											short ecStatus = orderInfo.getEcStatus();
											short ecPayStatus = orderInfo.getEcPayStatus();
											if (Objects.equals(ecStatus, Short.parseShort("1")) && Objects.equals(ecPayStatus, Short.parseShort("1"))) {
												String ecppid = ordertravpassport.getEcppid();
												if (Objects.nonNull(ecppid)) {
													PassportInfo passportInfo = passportInfoMapper.selectById(ecppid);
													if (Objects.nonNull(passportInfo)) {
														Map<String, String> hashMap = new HashMap<>();
														Map<String, String> convertMalaysiaSubmitInfo = convertPassportSubmitInfo(passportInfo,"0065");
														Map<String, String> convertSingaporeTravelSubmitInfo = convertSingaporeTravelSubmitInfo(singaporeTravInfo);
														if (Objects.nonNull(convertMalaysiaSubmitInfo) && Objects.nonNull(convertSingaporeTravelSubmitInfo)) {
															hashMap.putAll(convertMalaysiaSubmitInfo);
															hashMap.putAll(convertSingaporeTravelSubmitInfo);
															submitList.add(hashMap);
														}
													}
												}
											}else {
												msgList.add("id="+orderid+"的订单信息不符合提交的标准");
											}
										}else {
											msgList.add("未获取id="+orderid+"的订单信息");
										}
									}
								}
							}
							
							//获取乘客总数量
							Integer titPernum = travelitinerary.getTitPernum();
							int paySuccessnum = submitList.size();
							String subtip = "一共选择提交"+titPernum+"人,成功提交"+paySuccessnum+"人。";
							msgList.add(0, subtip);
							if (paySuccessnum==0) {
								throw new Exception("提交失败");
							}else {
					            // 开启线程
					            ExecutorService cacheThreadPool = Executors.newCachedThreadPool();
					            Callable<Boolean> clientAction = new Callable<Boolean>() {
					                @Override
					                public Boolean call() throws Exception {
					            		for (int i = 0; i < submitList.size(); i++) {
											Map<String, String> submitMap = submitList.get(i);
											String[] register = SingaporeIcaRegUtil.register(chromeDriver,tempOcrDictionary, chromeCacheDictionary,submitMap,false);
											logger.error("---after singapore request:size-"+register.length+",result-"+register[1]+"--"+register[0]);
											if (register.length==2) {
												String IDNumber = register[1];
												if (StringUtils.isNotEmpty(IDNumber)) {
													//获取并回写
													String titid = singaporeTravInfo.getTitid();
													String guId = submitMap.get("guId").toString();
													//获取中间表
													List<Ordertravpassport> ordertravpassports = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("travid", titid).eq("ecppid", guId));
													if (CollectionUtils.isNotEmpty(ordertravpassports)) {
														Ordertravpassport ordertravpassport = ordertravpassports.get(0);
														writeIdnumber(IDNumber, null, ordertravpassport.getId(), null, singaporeTravInfo,null);
													}
												}else {
													logger.error("---after singapore request result-"+register[2]+"--"+register[0]);
												}
											}
										}
					                    return true;
					                }
					            };
					            try {
					                cacheThreadPool.submit(clientAction);
					            } catch (Exception e) {
					                logger.error("执行clientAction失败:" + e.getMessage(), e);
					            } finally {
					                cacheThreadPool.shutdown();
					            }
							}
							resultMap.put("msgList", msgList);
							resultMap.put("subList", submitList);
							resultMap.put("titPernum", titPernum);
							resultMap.put("paySuccessnum", paySuccessnum);
						}else {
							msgList.add("未获取到该段行程的已支付成员的信息");
						}

					}else {
						msgList.add("未获取到该段行程信息");
					}
//					
//					//获取乘客总数量
//					Integer titPernum = travelitinerary.getTitPernum();
//					int paySuccessnum = submitList.size();
//					String subtip = "一共选择提交"+titPernum+"人,成功提交"+paySuccessnum+"人。";
//					msgList.add(0, subtip);
//					if (paySuccessnum==0) {
//						throw new Exception("提交失败");
//					}else {
//			            // 开启线程
//			            ExecutorService cacheThreadPool = Executors.newCachedThreadPool();
//			            Callable<Boolean> clientAction = new Callable<Boolean>() {
//			                @Override
//			                public Boolean call() throws Exception {
//			            		for (int i = 0; i < submitList.size(); i++) {
//									Map<String, String> submitMap = submitList.get(i);
//									String[] register = SingaporeIcaRegUtil.register(chromeDriver,tempOcrDictionary,submitMap,false);
//									logger.error("执行成功："+register);
//								}
//			                    return true;
//			                }
//			            };
//			            try {
//			                cacheThreadPool.submit(clientAction);
//			            } catch (Exception e) {
//			                logger.error("执行clientAction失败:" + e.getMessage(), e);
//			            } finally {
//			                cacheThreadPool.shutdown();
//			            }
//					}
//					resultMap.put("msgList", msgList);
//					resultMap.put("subList", submitList);
//					resultMap.put("titPernum", titPernum);
//					resultMap.put("paySuccessnum", paySuccessnum);
				}else if (Objects.equals(countryCode, "0066")) {
				
					List<Map<String,Object>> submitList = new LinkedList<>();

					QueryWrapper<ThailandTravInfo> queryWrapper = new QueryWrapper<>();
					queryWrapper.eq("titid", travid).eq("trow", row);
					List<ThailandTravInfo> thailandTravInfoList = thailanTravInfoMapper.selectList(queryWrapper);
					if (CollectionUtils.isNotEmpty(thailandTravInfoList)) {
						ThailandTravInfo thailandTravInfo = thailandTravInfoList.get(0);
						//获取支付信息
						QueryWrapper<Ordertravpassport> queryWrapper2 = new QueryWrapper<Ordertravpassport>();
						queryWrapper2.eq("travid", travid);
						List<Ordertravpassport> ordertravpassports = ordertravpassportMapper.selectList(queryWrapper2);
						if (CollectionUtils.isNotEmpty(ordertravpassports)) {
							for (int i = 0; i < ordertravpassports.size(); i++) {
								Ordertravpassport ordertravpassport = ordertravpassports.get(i);
								if (Objects.nonNull(ordertravpassport)) {
									String orderid = ordertravpassport.getOrderid();
									if (Objects.nonNull(orderid)) {
										OrderInfo orderInfo = orderInfoMapper.selectById(orderid);
										if (Objects.nonNull(orderInfo)) {
											short ecStatus = orderInfo.getEcStatus();
											short ecPayStatus = orderInfo.getEcPayStatus();
											if (Objects.equals(ecStatus, Short.parseShort("1")) && Objects.equals(ecPayStatus, Short.parseShort("1"))) {
												String ecppid = ordertravpassport.getEcppid();
												if (Objects.nonNull(ecppid)) {
													PassportInfo passportInfo = passportInfoMapper.selectById(ecppid);
													if (Objects.nonNull(passportInfo)) {
														Map<String, Object> hashMap = new HashMap<>();
														hashMap.put("passportInfo", passportInfo);
														hashMap.put("thailandTravInfo", thailandTravInfo);
														submitList.add(hashMap);
													}
												}
											}else {
												msgList.add("id="+orderid+"的订单信息不符合提交的标准");
											}
										}else {
											msgList.add("未获取id="+orderid+"的订单信息");
										}
									}
								}
							}
							
							//获取乘客总数量
							Integer titPernum = travelitinerary.getTitPernum();
							int paySuccessnum = submitList.size();
							String subtip = "一共选择提交"+titPernum+"人,成功提交"+paySuccessnum+"人。";
							msgList.add(0, subtip);
							if (paySuccessnum==0) {
								throw new Exception("提交失败");
							}else {
					            // 开启线程
					            ExecutorService cacheThreadPool = Executors.newCachedThreadPool();
					            Callable<Boolean> clientAction = new Callable<Boolean>() {
					                @Override
					                public Boolean call() throws Exception {
					            		for (int i = 0; i < submitList.size(); i++) {
											Map<String, Object> submitMap = submitList.get(i);
											
											logger.error("---before thailand request:result-"+JSON.toJSONString(submitMap)+"--");
											
											//个人信息
											PassportInfo passportInfo = JSONObject.parseObject(JSON.toJSONString(submitMap.get("passportInfo")),PassportInfo.class);
											//旅行信息
											ThailandTravInfo thailandTravInfo = JSONObject.parseObject(JSON.toJSONString(submitMap.get("thailandTravInfo")),ThailandTravInfo.class);
//									       	//执行请求
											convertThailandTravelSubmitInfo(passportInfo,thailandTravInfo);
										}
					                    return true;
					                }
					            };
					            try {
					                cacheThreadPool.submit(clientAction);
					            } catch (Exception e) {
					                logger.error("执行clientAction失败:" + e.getMessage(), e);
					            } finally {
					                cacheThreadPool.shutdown();
					            }
							}
							resultMap.put("msgList", msgList);
							resultMap.put("subList", submitList);
							resultMap.put("titPernum", titPernum);
							resultMap.put("paySuccessnum", paySuccessnum);
						}else {
							msgList.add("未获取到该段行程的已支付成员的信息");
						}
					}else {
						msgList.add("未获取到该段行程信息");
					}
				}
			}else {
				throw new Exception("缺少提交所需的关键信息");
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return resultMap;
	}
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public Map convertPassportSubmitInfo(PassportInfo passportInfo, String countryCode) {
		// TODO Auto-generated method stub
		Map resultMap = new HashMap<>();
		
        SimpleDateFormat simpleDateFormatyyyyMMdd = new SimpleDateFormat("yyyyMMdd");
        SimpleDateFormat simpleDateFormatddMMyyyy = new SimpleDateFormat("dd/MM/yyyy");
        SimpleDateFormat simpleDateFormatdd_MM_yyyy = new SimpleDateFormat("ddMMyyyy");
		try {
			resultMap.put("guId", passportInfo.getId());
			if (Objects.nonNull(passportInfo) && Objects.equals(countryCode, "0060")) {
				String guSexEn = passportInfo.getGuSexEn();
				String sexString = guSexEn.equals("MALE")?"1":"2";
				
				String guFamiNameEn = passportInfo.getGuFamiNameEn();
				String guFirstNameEn = passportInfo.getGuFirstNameEn();
				String guPassportNum = passportInfo.getGuPassportNum();
				
				String guExpiryDate = passportInfo.getGuExpiryDate();
				Date parse1 = simpleDateFormatyyyyMMdd.parse(guExpiryDate);
				String expiryDate = simpleDateFormatddMMyyyy.format(parse1);

				String guNationalityCn = passportInfo.getGuNationalityCn();
				//国籍判断获取
				String guNationalityEn = StringUtil.getThreeNationaInfo(guNationalityCn);
				
				String guBirthDate = passportInfo.getGuBirthDate();
				Date parse = simpleDateFormatyyyyMMdd.parse(guBirthDate);
				String birthDate = simpleDateFormatddMMyyyy.format(parse);
				//创建容器
				resultMap.put("hdCurrLang","ms");
				resultMap.put("name",guFamiNameEn+" "+guFirstNameEn);
				resultMap.put("passNo",guPassportNum);
				resultMap.put("dob",birthDate);
				resultMap.put("nationality",guNationalityEn);
				resultMap.put("sex",sexString);
				resultMap.put("passExpDte",expiryDate);							        
			}else if(Objects.nonNull(passportInfo) && Objects.equals(countryCode, "0065")) {
				String guFamiNameEn = passportInfo.getGuFamiNameEn();
				String guFirstNameEn = passportInfo.getGuFirstNameEn();
				String guPassportNum = passportInfo.getGuPassportNum();
				
				String guExpiryDate = passportInfo.getGuExpiryDate();
				Date parse1 = simpleDateFormatyyyyMMdd.parse(guExpiryDate);
				String expiryDate = simpleDateFormatdd_MM_yyyy.format(parse1);
				
				String guSexEn = passportInfo.getGuSexEn();
				String sexString = guSexEn.equals("MALE")?"M":"F";
				
				String guBirthDate = passportInfo.getGuBirthDate();
				Date parse = simpleDateFormatyyyyMMdd.parse(guBirthDate);
				String birthDate = simpleDateFormatdd_MM_yyyy.format(parse);
				
				String guNationalityEn = passportInfo.getGuNationalityEn();
				
				resultMap.put("fullName",guFamiNameEn+" "+guFirstNameEn);
				resultMap.put("passportNumber",guPassportNum);
				resultMap.put("passportExpiry",expiryDate);    //注意日期格式，不能有/分割，否则会错
				resultMap.put("sex",sexString);
				resultMap.put("birthday",birthDate);  //注意日期格式，不能有/分割，否则会错
				resultMap.put("nationality",guNationalityEn);
				resultMap.put("countryOfBirth","CHINA");
			}else if(Objects.nonNull(passportInfo) && Objects.equals(countryCode, "0066")) {
				//姓名
				String guFamiNameEn = passportInfo.getGuFamiNameEn();
				resultMap.put("guFamiNameEn",guFamiNameEn);
				String guFirstNameEn = passportInfo.getGuFirstNameEn();
				resultMap.put("guFirstNameEn",guFirstNameEn);				
				String guPassportNum = passportInfo.getGuPassportNum();
				resultMap.put("guPassportNum",guPassportNum);				
				String guSexEn = passportInfo.getGuSexEn();
				resultMap.put("guSexEn",guSexEn);    //注意日期格式，不能有/分割，否则会错				
				String guBirthDate = passportInfo.getGuBirthDate();
				resultMap.put("guBirthDate",guBirthDate);				
				String guNationalityEn = passportInfo.getGuNationalityEn();
				resultMap.put("guNationalityEn",guNationalityEn);  //注意日期格式，不能有/分割，否则会错				
				String occupationEn = passportInfo.getOccupationEn();	
				resultMap.put("occupationEn",occupationEn);
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return resultMap;
	}
	
	@Override
	public Map<String, Object> convertMalaysiaTravelSubmitInfo(Malaysiatravinfo malaTravInfo) {
		// TODO Auto-generated method stub
		Map<String, Object> resultMap = new HashMap<>();
		
        SimpleDateFormat simpleDateFormatddMMyyyy = new SimpleDateFormat("dd/MM/yyyy");

		try {
			if (Objects.nonNull(malaTravInfo)) {
				logger.error("旅行信息："+JSON.toJSONString(malaTravInfo));
				//入境日期
				Date dateofentry = malaTravInfo.getDateofentry();
				String entryDate = simpleDateFormatddMMyyyy.format(dateofentry);
				//离境日期
				Date dateofleave = malaTravInfo.getDateofleave();
				String leaveDate = simpleDateFormatddMMyyyy.format(dateofleave);
				//获取住宿方式
				String accommodationStay = "";
				String residentialmode = malaTravInfo.getResidentialmode();
				if (Objects.equals(residentialmode, "HOTEL/MOTEL/REST HOUSE")) {
					accommodationStay = "01";
				}else if (Objects.equals(residentialmode, "RESIDENCE OF FRIENDS/RELATIVES")) {
					accommodationStay = "02";
				}else if (Objects.equals(residentialmode, "RESIDENCE OF FRIENDS/RELATIVES")) {
					accommodationStay = "99";
				}
				//获取所在的州
				String stateCode = malaTravInfo.getStateofresidence();
				//获取所在的城市
				String cityCode = malaTravInfo.getCityofresidence();
				//获取详细地址
				String addressofstay = malaTravInfo.getAddressofstay();
				//获取右边
				String postcode = malaTravInfo.getPostcode();
				//交通方式
				String entrymethodCode = "";
				String entrymethod = malaTravInfo.getEntrymethod();
				if (Objects.equals(entrymethod, "AIR")) {
					entrymethodCode = "1";
				}else if (Objects.equals(entrymethod, "LAND")) {
					entrymethodCode = "2";
				}else if (Objects.equals(entrymethod, "SEA")) {
					entrymethodCode = "3";
				}
				//号码
				String flightno = malaTravInfo.getFlightno();
				//获取国家
				String countryofstay = malaTravInfo.getCountryofstay();
				//手机号
				String region = malaTravInfo.getRegion();
				String mobile = malaTravInfo.getMobile();
				
				resultMap.put("region",region);
				resultMap.put("confirmRegion",region);
				resultMap.put("mobile",mobile);
				resultMap.put("confirmMobile",mobile);
				resultMap.put("arrDt",entryDate);
				resultMap.put("depDt",leaveDate);
				resultMap.put("trvlMode",entrymethodCode);
				resultMap.put("vesselNm",flightno);
				resultMap.put("embark",countryofstay);
				resultMap.put("accommodationStay",accommodationStay);
				resultMap.put("accommodationAddress1",addressofstay);
				resultMap.put("accommodationAddress2","");
				resultMap.put("accommodationState",stateCode);
				resultMap.put("accommodationPostcode",postcode);
				resultMap.put("accommodationCity",cityCode);
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return resultMap;
	}
	
	@Override
	public Map<String, String> convertSingaporeTravelSubmitInfo(SingaporeTravInfo singaporeTravInfo) {
		// TODO Auto-generated method stub
		Map<String, String> resultMap = new HashMap<>();
		try {
	        SimpleDateFormat simpleDateFormatddMMyyyy = new SimpleDateFormat("dd/MM/yyyy");
	        SimpleDateFormat simpleDateFormatdd_MM_yyyy = new SimpleDateFormat("ddMMyyyy");

			//入境日期
			Date dateofentry = singaporeTravInfo.getDateofentry();
			String dateOfArrival = simpleDateFormatddMMyyyy.format(dateofentry);
			//离境日期
			Date dateofleave = singaporeTravInfo.getDateofleave();
			String departureDate = simpleDateFormatdd_MM_yyyy.format(dateofleave);
			//常居地
			String placeOfResidence = singaporeTravInfo.getPlaceOfResidence();
			//邮箱
			String email = singaporeTravInfo.getEmail();
			//手机
			String mobile = singaporeTravInfo.getMobile();
			//区号
			String region = singaporeTravInfo.getRegion();
			//上一站的城市
			String cityofBeforeEntry = singaporeTravInfo.getCityofBeforeEntry();
			//旅行目的
			String purposeoftravel = singaporeTravInfo.getPurposeoftravel();
			//下一站城市
			String cityofAfterLeave = singaporeTravInfo.getCityofAfterLeave();
			//旅馆名称
			String addressofstay = singaporeTravInfo.getAddressofstay();
			if (Objects.equals(addressofstay.trim().toUpperCase(), "OTHERS")) {
				resultMap.put("accommodationType","O");
//				resultMap.put("otherAccommodation","TRANSIT");
		        resultMap.put("otherAccommodation","DAY_TRIP");
			}else {
				resultMap.put("accommodationType","H");
			}
			
			resultMap.put("email",email);
			resultMap.put("countryCode",region);
			resultMap.put("mobile",mobile);
			resultMap.put("purposeOfTravel",purposeoftravel);
			resultMap.put("hotelName",addressofstay);
			resultMap.put("dateOfArrival",dateOfArrival);   //注意修改
			resultMap.put("departureDate",departureDate); //注意日期格式
			resultMap.put("residence",placeOfResidence);
			resultMap.put("lastCity",cityofBeforeEntry);
			resultMap.put("nextCity",cityofAfterLeave);

			resultMap.put("healthDeclaration1","NO"); // 默认NO，可不填写
			resultMap.put("healthDeclaration2","NO"); // 默认NO，可不填写
			resultMap.put("healthDeclaration3","NO");
			
			String entrymethod = singaporeTravInfo.getEntrymethod();
			if (Objects.equals(entrymethod, "AIR")) {
				String airlineCompany = singaporeTravInfo.getAirlineCompany();
				String flightNo = StringUtil.getCharNumByString(singaporeTravInfo.getFlightno())[1];
//				String transportMode = StringUtil.getCharNumByString(singaporeTravInfo.getFlightno())[0];
				
				resultMap.put("travelMode","A");
	            // COMMERCIAL FLIGHT
				resultMap.put("transportMode","CA");
				resultMap.put("carrierCode",airlineCompany);
				resultMap.put("flightNo",flightNo);
			}else if (Objects.equals(entrymethod, "LAND")) {
				String flightno = singaporeTravInfo.getFlightno();
				resultMap.put("travelMode","L");
				resultMap.put("transportMode","CAR");
				resultMap.put("vehicleNo",flightno);   //对方网站仅仅支持英文字母加数字
			}
			
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return resultMap;
	}
	
	@Override
	public Map<String, Object> convertThailandTravelSubmitInfo(PassportInfo passportInfo,ThailandTravInfo thailandTravInfo) {
		// TODO Auto-generated method stub
		Map<String, Object> thailandNation = StringUtil.getThailandNation();
		Map<String, Object> resultMap = new HashMap<>();
		try {
	        SimpleDateFormat simpleDateFormatddMMyyyy = new SimpleDateFormat("yyyy/MM/dd");
	        PersonInfoView personInfoView = new PersonInfoView();
	        //姓名
	        String guFamiNameEn = passportInfo.getGuFamiNameEn();
	        personInfoView.setFamilyName(guFamiNameEn);
	        String guFirstNameEn = passportInfo.getGuFirstNameEn();
	        personInfoView.setFirstName(guFirstNameEn);
	        //性别
	        String guSexEn = passportInfo.getGuSexEn();
	        personInfoView.setGender(new BaseModel(guSexEn));
	        //出生日期
	        String guBirthDate = passportInfo.getGuBirthDate();
    		if (guBirthDate.length()==8) {
				String birthYear = guBirthDate.substring(0, 4);
				personInfoView.setBdDateYear(birthYear);
				String birthMon = guBirthDate.substring(4, 6);
				personInfoView.setBdDateMonth(birthMon);
				String birthDay = guBirthDate.substring(6, 8);
				personInfoView.setBdDateDay(birthDay);
			}else {
				throw new Exception("未获取到正确的出生日期");
			}
	        //护照号
	        String guPassportNum = passportInfo.getGuPassportNum();
	        personInfoView.setPassportNo(guPassportNum);
	        //国籍
	        String guNationalityEn = passportInfo.getGuNationalityEn();
	        if (Objects.equals(guNationalityEn.toUpperCase(), "CHINESE")) {
	        	guNationalityEn = "CHN";
			}
	        if (thailandNation.containsKey(guNationalityEn)) {
				String nationalityEn = thailandNation.get(guNationalityEn).toString();
				personInfoView.setNationality(new BaseModel(nationalityEn,guNationalityEn));
			}else {
				throw new Exception("未获取到正确的国籍");
			}
	        //职业
	        String occupationEn = passportInfo.getOccupationEn();
	        personInfoView.setOccupation(occupationEn);
	        //区号
//	        String countryCode = thailandTravInfo.getCountryCode();
	        personInfoView.setPhoneCode("86");
	        //手机号
	        String mobile = thailandTravInfo.getMobile();
	        personInfoView.setPhoneNo(mobile);
	        personInfoView.setVisaNo("");
	        //常居地
	        String placeOfResidence = thailandTravInfo.getPlaceOfResidence();
	        personInfoView.setCityRes(new BaseModel(placeOfResidence, placeOfResidence));
	        //国家
	        personInfoView.setCountryRes(new BaseModel("CHN : PEOPLE'S REPUBLIC OF CHINA","china"));//居住城市
	        
	        TripInfoView tripInfoView = new TripInfoView();
	        //目的
	        String purposeoftravel = thailandTravInfo.getPurposeoftravel();
	        tripInfoView.setTraPurpose(new BaseModel(purposeoftravel));
	        //入境日期
	        Date dateofentry = thailandTravInfo.getDateofentry();
	        String entryDate = simpleDateFormatddMMyyyy.format(dateofentry);
	        tripInfoView.setArrDate(entryDate);
	        String departureCountry = thailandTravInfo.getDepartureCountry();
	        String beforeStayCountry = StringUtil.getBeforeStayCountryByName(departureCountry);
    		tripInfoView.setCountryBoard(new BaseModel(beforeStayCountry,beforeStayCountry.split(":")[0].trim()));
	        //入境方式
	        String entryMethod = thailandTravInfo.getEntryMethod();
	        tripInfoView.setTraMode(new BaseModel(entryMethod));
	        if (Objects.equals(entryMethod, "AIR")) {
				tripInfoView.setTranMode(new BaseModel("COMMERCIAL FLIGHT"));
			} else if (Objects.equals(entryMethod, "LAND")) {
				tripInfoView.setTranMode(new BaseModel("CAR"));
			} else if (Objects.equals(entryMethod, "SEA")) {
				tripInfoView.setTranMode(new BaseModel("CRUISE"));
			}
	        //航班号
	        String flightNo = thailandTravInfo.getFlightNo();
	        tripInfoView.setFlightNo(flightNo);
	        //是否过境
	        Short transit = thailandTravInfo.getTransit();
	        if (Objects.equals(transit, Short.parseShort("1"))) {
				tripInfoView.setNotStayInTh(true);
			}else {
				tripInfoView.setNotStayInTh(false);
			}
	        //离境日期
	        Date dateofleave = thailandTravInfo.getDateofleave();
    		//没有填写离境日期
    		if (Objects.isNull(dateofleave)) {
    			tripInfoView.setDeptDate(null);     //离境日期
    	        tripInfoView.setDeptTraMode(null);  //离境旅行方式
    	        tripInfoView.setDeptFlightNo("");   //离境航班号
    			tripInfoView.setNotStayInTh(false);
			}else {
		        String leavedate = simpleDateFormatddMMyyyy.format(dateofleave);
				tripInfoView.setDeptDate(leavedate);
		        //离境方式
		        String leaveMethod = thailandTravInfo.getLeaveMethod();
				tripInfoView.setDeptTraMode(new BaseModel(leaveMethod));
	    		if (Objects.equals(leaveMethod, "AIR")) {
					tripInfoView.setDeptTranMode(new BaseModel("COMMERCIAL FLIGHT"));
				} else if (Objects.equals(leaveMethod, "LAND")) {
					tripInfoView.setDeptTranMode(new BaseModel("CAR"));
				} else if (Objects.equals(leaveMethod, "SEA")) {
					tripInfoView.setDeptTranMode(new BaseModel("CRUISE"));
				}
		        //离境航班
		        String leaveflightNo = thailandTravInfo.getLeaveflightNo();
	    		tripInfoView.setDeptFlightNo(leaveflightNo);
			}
	        //居住方式
	        String residentialmode = thailandTravInfo.getResidentialmode();
			if (StringUtils.isNotEmpty(residentialmode)) {
	    		tripInfoView.setAccType(new BaseModel(residentialmode));    //居住类型
		        //居住省府州
		        String stateofresidence = thailandTravInfo.getStateofresidence();
		        if (StringUtils.isNotEmpty(stateofresidence)) {
		    		tripInfoView.setAccProvince(new BaseModel(stateofresidence,stateofresidence));
		    		String cityofresidence = thailandTravInfo.getCityofresidence();
		    		if (StringUtils.isNotEmpty(cityofresidence)) {
			    		tripInfoView.setAccDistrict(new BaseModel(cityofresidence,cityofresidence));
			    		String streetofresidence = thailandTravInfo.getStreetofresidence();
			    		if (StringUtils.isNotEmpty(streetofresidence)) {
				    		tripInfoView.setAccSubDistrict(new BaseModel(streetofresidence,streetofresidence));
						}
					}
				}
		        String specificaddress = thailandTravInfo.getSpecificaddress();
	    		 if (StringUtils.isNotEmpty(specificaddress)) {
			    		tripInfoView.setAccAddress(specificaddress);
				}
			}
	        //滞留国家
	        String stayBeforeEntryCountry = thailandTravInfo.getStayBeforeEntryCountry();
	        String[] arr = stayBeforeEntryCountry.split("-");
	        List<BaseModel> linkedList = new LinkedList<>();
	        for (int i = 0; i < arr.length; i++) {
	        	String beforeStayCountryByName = StringUtil.getBeforeStayCountryByName(arr[i]);
    			//设置搜索项
    			String arrString = beforeStayCountryByName.split(":")[0].trim();
    			//设置国家值
				BaseModel baseModel = new BaseModel(beforeStayCountryByName,arrString);
				linkedList.add(baseModel);
			}
	        //邮箱
	        String email = thailandTravInfo.getEmail();
	        logger.error("----thailand--param--personInfo--"+JSON.toJSONString(personInfoView));
	        logger.error("----thailand--param--tripInfo--"+JSON.toJSONString(tripInfoView));
			RespView respView = ThailandRegUtil.register(null, null, personInfoView, tripInfoView, linkedList, email, true);
			if (Objects.nonNull(respView)) {
				List<TravellerResModel> travellerReslList = respView.getTravellerReslList();
				if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(travellerReslList)) {
					TravellerResModel travellerResModel = travellerReslList.get(0);
					if (Objects.nonNull(travellerResModel)) {
						//获取并回写
						String titid = thailandTravInfo.getTitid();
						String guId = passportInfo.getId();
						//获取中间表
						List<Ordertravpassport> ordertravpassports = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("travid", titid).eq("ecppid", guId));
						if (CollectionUtils.isNotEmpty(ordertravpassports)) {
							Ordertravpassport ordertravpassport = ordertravpassports.get(0);
							//获取pin码
							String arrCardNo = travellerResModel.getArrCardNo();
							//pin链接
							Connection connection = respView.getConnection();
							String pinUrl = null;
							if (Objects.nonNull(connection)) {
								Response response = connection.method(Connection.Method.POST).execute();
								//定义文件名称
								String fileNameString = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+passportInfo.getGuPassportNum()+".PDF";
								String dirPathString = "C:\\temp\\thailand";
								//请求方法
								pinUrl = FileControl.saveFilebyRead(dirPathString, fileNameString, response.bodyStream());
								//删除本地文件
								FileControl.deleteFile(dirPathString+"\\\\"+fileNameString);
							}
							writeIdnumber(arrCardNo, pinUrl, ordertravpassport.getId(), null, null, thailandTravInfo);
						}
					}
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return resultMap;
	}
	
	@Override
	public List<PassportInfo> uploadExcelFile(MultipartFile file) {
		// TODO Auto-generated method stub
		List<PassportInfo> passportList = new LinkedList<>();
		try {
			File tempFile = null;
			if (!file.isEmpty()) {
				String format = new SimpleDateFormat("yyyyMMdd").format(new Date());
                String contextpath = "/usr/tempfileDir/"+format;
                File f = new File(contextpath);
                if (!f.exists()) {
                    f.mkdirs();
                }

                //在tempfileDir的临时文件夹下创建一个新的和上传文件名一样的文件
                String filename = file.getOriginalFilename() + new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
                String filepath = contextpath + "/" + filename;
                FileControl.saveFile(file.getInputStream(), filepath);
                //save to the /upload path
                tempFile = new File(filepath);
                FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile);
                //获取字节流
                InputStream inputStream = new FileInputStream(tempFile);
                //读取excel表格
    			ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader(inputStream);
//    			logger.error("文件内容："+JSON.toJSONString(reader.read()));
    			//获取列明所在行号
    			int lineNoRow = 99;
    			int lineNameRow = 99;
    			List<List<Object>> readallData = reader.read();
    			for (int i = 0; i < readallData.size(); i++) {
    				String rowString = readallData.get(i).toString();
    				if ((rowString.contains("證件") || rowString.contains("护照")) && (rowString.contains("性别") || rowString.contains("性別")) && rowString.contains("出生")) {
    					lineNameRow = i;
    					if (lineNoRow!=99 && lineNameRow!=99) {
    						break;
						}
    				}
    				List<Object> columnlist = readallData.get(i);
    				for (int j = 0; j < columnlist.size(); j++) {
    					if (Objects.nonNull(columnlist.get(j))) {
    						String noLieString = columnlist.get(j).toString();
    						if (noLieString.contains("序号") || noLieString.contains("编号") ||  noLieString.contains("編號")) {
    							if (lineNoRow==99) {
    								lineNoRow = j;
    							}
    							if (lineNoRow!=99 && lineNameRow!=99) {
    								break;
    							}
    						}
    					}
    				}
    			}
//    			logger.error("lineNoRow:"+lineNoRow+",lineNameRow:"+lineNameRow);
    			//获取数据
    	        if (lineNameRow==99 || lineNoRow==99) {
    				throw new Exception("未获取到列名、序号所在列");
    			}else {
        			//获取列明行数据
        			List<Object> lineNameList = readallData.get(lineNameRow);
    				List<Map<String,Object>> linkedList = new LinkedList<>();
    				//数据在列名所咋行的下一行
    				for (int i = lineNameRow+1; i < readallData.size(); i++) {
    					List<Object> rowlist = readallData.get(i);
    					//通过第一列的数字来判断是否到达最后一行
    					if (!rowlist.get(lineNoRow).toString().contains("T") && !StringUtils.isNumeric(rowlist.get(lineNoRow).toString())) {
    						break;
    					}
    					Map<String,Object> hashMap = new HashMap<String,Object>();
    					//获取列明和数字组成map
    					for (int j = 0; j < lineNameList.size(); j++) {
    						Object cellobject =  rowlist.get(j);
    						//获取key
    						String mapKey = lineNameList.get(j).toString().replaceAll("\n", "").replaceAll("\\s*", "");
    						if (cellobject==null || Objects.equals(cellobject.toString(), "")) {
    							continue;
    						}
    						hashMap.put(mapKey, cellobject);
    					}
    					linkedList.add(hashMap);
    				}
//    				logger.error("文件内容map："+JSON.toJSONString(linkedList));
    				//所有的数据已经在list，我们通过数据来提取
    				for (int i = 0; i < linkedList.size(); i++) {
						Map<String, Object> passportmap = linkedList.get(i);
						//map转护照对象
						PassportInfo mapconverPassportInfo = mapconverPassportInfo(passportmap);
						passportList.add(mapconverPassportInfo);
					}
//    				logger.error("文件内容list："+JSON.toJSONString(passportList));
    			}
			}else {
				throw new Exception("空文件，请确认上传文件");
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return passportList;
	}
	
	@Override
	public PassportInfo mapconverPassportInfo(Map<String, Object> map) {
		// TODO Auto-generated method stub
		PassportInfo passportInfo = new PassportInfo();
		try {
			String id = StringUtil.getId();
			passportInfo.setId(id);
			//中文姓名
			String guName = "";
			if (map.containsKey("姓名") || map.containsKey("中文名") || map.containsKey("游客姓名") || map.containsKey("中文姓名") || map.containsKey("中文姓名CHINESENAME")) {
				if (map.containsKey("姓名")) {
					guName = map.get("姓名").toString();
				}else if (map.containsKey("中文名")) {
					guName = map.get("中文名").toString();
				}else if (map.containsKey("游客姓名")) {
					guName = map.get("游客姓名").toString();
				}else if (map.containsKey("中文姓名")) {
					guName = map.get("中文姓名").toString();
				}else if (map.containsKey("中文姓名CHINESENAME")) {
					guName = map.get("中文姓名CHINESENAME").toString();
				}
			}
			passportInfo.setGuName(guName);
			//英文姓名
			String guFirstName = "";
			String guFamilyName = "";
			if ((map.containsKey("姓拼音") && map.containsKey("名拼音")) || (map.containsKey("拼音姓") && map.containsKey("拼音名")) || (map.containsKey("英文姓") && map.containsKey("英文名"))
					|| map.containsKey("英文姓名(姓/名)") || map.containsKey("英文姓名(姓 名)") || map.containsKey("英文姓名") || map.containsKey("漢語拼音姓名NAMEINHANYUPINYIN(SURNAME,OTHERNAME)")
					 || map.containsKey("拼音姓名")) {
				if (map.containsKey("姓拼音") && map.containsKey("名拼音")) {
					guFirstName = map.get("名拼音").toString();
					guFamilyName = map.get("姓拼音").toString();
				}else if (map.containsKey("拼音姓") && map.containsKey("拼音名")) {
					guFirstName = map.get("拼音名").toString();
					guFamilyName = map.get("拼音姓").toString();
				}else if (map.containsKey("英文姓") && map.containsKey("英文名")) {
					guFirstName = map.get("英文名").toString();
					guFamilyName = map.get("英文姓").toString();
				}else if (map.containsKey("英文姓名(姓/名)")) {
					String engName = map.get("英文姓名(姓/名)").toString();
					if (engName.split("/").length==2) {
						guFamilyName = engName.split("/")[0];
						guFirstName = engName.split("/")[1];
					}
				}else if (map.containsKey("英文姓名(姓 名)")) {
					String engName = map.get("英文姓名(姓 名)").toString();
					if (engName.split(" ").length==2) {
						guFamilyName = engName.split(" ")[0];
						guFirstName = engName.split(" ")[1];
					}
				}else if (map.containsKey("漢語拼音姓名NAMEINHANYUPINYIN(SURNAME,OTHERNAME)")) {
					String engName = map.get("漢語拼音姓名NAMEINHANYUPINYIN(SURNAME,OTHERNAME)").toString();
					if (engName.split("/").length==2) {
						guFamilyName = engName.split("/")[0];
						guFirstName = engName.split("/")[1];
					}
				}else if (map.containsKey("拼音姓名")) {
					String engName = map.get("拼音姓名").toString();
					if (engName.split("/").length==2) {
						guFamilyName = engName.split("/")[0];
						guFirstName = engName.split("/")[1];
					}
				}else if (map.containsKey("英文姓名")) {
					String engName = map.get("英文姓名").toString();
					if (engName.split("/").length==2) {
						guFamilyName = engName.split("/")[0];
						guFirstName = engName.split("/")[1];
					}
				}
			}
			passportInfo.setGuFirstNameEn(guFirstName);
			passportInfo.setGuFamiNameEn(guFamilyName);
			//性别
			String guSexCn = "";
			String guSexEn = "";
			if (map.containsKey("性别") || map.containsKey("性別SEX")) {
				Object sexObject = null;
				if (map.containsKey("性别")) {
					sexObject = map.get("性别");
				}else if (map.containsKey("性別SEX")) {
					sexObject = map.get("性別SEX");
				}
				if (Objects.nonNull(sexObject)) {
					String sex = sexObject.toString();
					if (sex.length() == 1) {
						boolean matches = sex.matches("[a-zA-Z]");
						if (matches) {
							if (Objects.equals(sex, "F")) {
								guSexCn = "女";
								guSexEn = "FEMALE";
							}else if (Objects.equals(sex, "M")) {
								guSexCn = "男";
								guSexEn = "MALE";
							}
						}else {
							if (Objects.equals(sex, "女")) {
								guSexCn = "女";
								guSexEn = "FEMALE";
							}else if (Objects.equals(sex, "男")) {
								guSexCn = "男";
								guSexEn = "MALE";
							}
						}
					}else if (sex.length() > 1) {
						if (Objects.equals(sex, "FEMALE")) {
							guSexCn = "女";
							guSexEn = "FEMALE";
						}else if (Objects.equals(sex, "MALE")) {
							guSexCn = "男";
							guSexEn = "MALE";
						}
					}
				}
			}
			passportInfo.setGuSexCn(guSexCn);
			passportInfo.setGuSexEn(guSexEn);
			//出生日期
			String birthDate = "";
			if (map.containsKey("出生日期") || map.containsKey("出生日期D.O.B(YYYY/MM/DD)")) {
				Object birthDateObject = null;
				if (map.containsKey("出生日期")) {
					birthDateObject = map.get("出生日期");
				}else if (map.containsKey("出生日期D.O.B(YYYY/MM/DD)")) {
					birthDateObject = map.get("出生日期D.O.B(YYYY/MM/DD)");
				}
				if (Objects.nonNull(birthDateObject)) {
					Date birthDateDate = DateUtil.convertStringToDate(birthDateObject);
					if (Objects.nonNull(birthDateDate)) {
						birthDate = new SimpleDateFormat("yyyyMMdd").format(birthDateDate);
					}
				}
			}
			passportInfo.setGuBirthDate(birthDate);
			//出生地
			String guBirthPlaceCn = "";
			String guBirthPlaceEn = "";
			if (map.containsKey("出生地") || map.containsKey("出生地PLACEOFBIRTH")) {
				Object birthPlaceObject = null;
				if (map.containsKey("出生地")) {
					birthPlaceObject = map.get("出生地");
				}else if (map.containsKey("出生地PLACEOFBIRTH")) {
					birthPlaceObject = map.get("出生地PLACEOFBIRTH");
				}
				if (Objects.nonNull(birthPlaceObject)) {
					String birthPlace = birthPlaceObject.toString().replaceAll("\\s*", "");
					//判断是字符还是汉字
					if (birthPlace.matches("[a-zA-z]+")) {
						guBirthPlaceCn = StringUtil.getCityInfo(birthPlace);
						guBirthPlaceEn = birthPlace;
					}else {
						guBirthPlaceCn = birthPlace;
						guBirthPlaceEn = PinyinUtil.getPinyin(birthPlace).toUpperCase().replaceAll("\\s*", "");;
					}
				}
			}
			passportInfo.setGuBirthPlaceCn(guBirthPlaceCn);
			passportInfo.setGuBirthPlaceEn(guBirthPlaceEn);
			//护照号
			String guPassportNum = "";
			if (map.containsKey("护照号") || map.containsKey("护照号码") ||map.containsKey("证件号码") || map.containsKey("證件號碼") || map.containsKey("證件號碼T/DNO.")) {
				if (map.containsKey("护照号")) {
					guPassportNum = map.get("护照号").toString();
				}else if (map.containsKey("护照号码")) {
					guPassportNum = map.get("护照号码").toString();
				}else if (map.containsKey("证件号码")) {
					guPassportNum = map.get("证件号码").toString();
				}else if (map.containsKey("證件號碼T/DNO.")) {
					guPassportNum = map.get("證件號碼T/DNO.").toString();
				}
			}
			passportInfo.setGuPassportNum(guPassportNum);
			//护照签发日期
			String guIssueDate = "";
			if (map.containsKey("签发日期") || map.containsKey("护照签发日期") || map.containsKey("签发日期DATEOFISSUE")) {
				Object issueDateObject = null;
				if (map.containsKey("签发日期")) {
					issueDateObject = map.get("签发日期");
				}else if (map.containsKey("护照签发日期")) {
					issueDateObject = map.get("护照签发日期");
				}else if (map.containsKey("签发日期DATEOFISSUE")) {
					issueDateObject = map.get("签发日期DATEOFISSUE");
				}
				if (Objects.nonNull(issueDateObject)) {
					Date issueDateDate = DateUtil.convertStringToDate(issueDateObject);
					if (Objects.nonNull(issueDateDate)) {
						guIssueDate = new SimpleDateFormat("yyyyMMdd").format(issueDateDate);
					}
				}
			}
			passportInfo.setGuIssueDate(guIssueDate);
			//签发地
			String guIssuePlaceCn = "";
			String guIssuePlaceEn = "";
			if (map.containsKey("签发地") || map.containsKey("护照签发地") || map.containsKey("簽發地PLACEOFISSUE")) {
				Object placeObject = null;
				if (map.containsKey("签发地")) {
					placeObject = map.get("签发地");
				}else if (map.containsKey("护照签发地")) {
					placeObject = map.get("护照签发地");
				}else if (map.containsKey("簽發地PLACEOFISSUE")) {
					placeObject = map.get("簽發地PLACEOFISSUE");
				}
				if (Objects.nonNull(placeObject)) {
					String issuePlace = placeObject.toString().replaceAll("\\s*", "");;
					if (issuePlace.matches("[a-zA-Z]+")) {
						guIssuePlaceCn = StringUtil.getCityInfo(issuePlace);
						guIssuePlaceEn = issuePlace;
					}else {
						guIssuePlaceCn = issuePlace;
						guIssuePlaceEn = PinyinUtil.getPinyin(issuePlace).toUpperCase().replaceAll("\\s*", "");;
					}
				}
			}
			passportInfo.setGuIssuePlaceCn(guIssuePlaceCn);
			passportInfo.setGuIssuePlaceEn(guIssuePlaceEn);
			//护照有效期
			String guExpiryDate = "";
			if (map.containsKey("有效期") || map.containsKey("有效日期") || map.containsKey("护照有效期") || map.containsKey("护照有效日期") || map.containsKey("有效期DATEOFEXPIRY")) {
				Object expiryDateObject = null;
				if (map.containsKey("有效期")) {
					expiryDateObject = map.get("有效期");
				}else if (map.containsKey("有效日期")) {
					expiryDateObject = map.get("有效日期");
				}else if (map.containsKey("护照有效期")) {
					expiryDateObject = map.get("护照有效期");
				}else if (map.containsKey("护照有效日期")) {
					expiryDateObject = map.get("护照有效日期");
				}else if (map.containsKey("有效期DATEOFEXPIRY")) {
					expiryDateObject = map.get("有效期DATEOFEXPIRY");
				}
				if (Objects.nonNull(expiryDateObject)) {
					Date expiryDateDate = DateUtil.convertStringToDate(expiryDateObject);
					if (Objects.nonNull(expiryDateDate)) {
						guExpiryDate = new SimpleDateFormat("yyyyMMdd").format(expiryDateDate);
					}
				}
			}
			passportInfo.setGuExpiryDate(guExpiryDate);
			//国籍
			String guNationalityCn = "";
			String guNationalityEn = "";
			if (map.containsKey("国籍")) {
				Object nation = map.get("国籍");
				if (Objects.nonNull(nation)) {
					String guNation = nation.toString().replaceAll("\\s*", "");
					String nationaInfo = StringUtil.getNationaInfo(guNation);
					if (nationaInfo.contains("/")) {
						guNationalityCn = nationaInfo.split("/")[0];
						guNationalityEn = nationaInfo.split("/")[1].toUpperCase();
					}else {
						throw new Exception("国籍识别有误");
					}
				}
			}
			passportInfo.setGuNationalityCn(guNationalityCn);
			passportInfo.setGuNationalityEn(guNationalityEn);
			//写入时间戳
			passportInfo.setPubts(new Date());
			PassportInfo passInfo = passportInfoMapper.selectOne(new QueryWrapper<PassportInfo>().eq("gu_passport_num",guPassportNum));
			if (Objects.nonNull(passInfo)) {
				String passportid = passInfo.getId();
				passportInfo.setId(passportid);
			}
			if (Objects.isNull(passportInfo.getGuPassportNum())) {
				throw new Exception("缺少护照号码");
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return passportInfo;
	}
	
	@Override
	public PageInfo<LeaderInfo> getPageLeaderInfo(Map<String, Object> map) {
		// TODO Auto-generated method stub
		try {
			if (map.containsKey("lgId")) {
				if (map.containsKey("pageIndex") && map.containsKey("pageSize")) {
					Integer pageIndex = Integer.parseInt(map.get("pageIndex").toString());
					Integer pageSize = Integer.parseInt(map.get("pageSize").toString());
					//查询条件
					String lgId = map.get("lgId").toString();
					QueryWrapper<LeaderInfo> queryWrapper = new QueryWrapper<>();
					queryWrapper.orderByDesc("pubts");
					queryWrapper.eq("lg_id", lgId);
					if (map.containsKey("word") && StringUtils.isNotEmpty(map.get("word").toString())) {
						String word = map.get("word").toString();
						queryWrapper.like("tl_name", word).or().like("tl_code", word).or().like("tl_travel_agency", word);
					}
//					Integer selectCount = leaderInfoMapper.selectCount(queryWrapper);
//					if (selectCount==0) {
//						return new Page<>();
//					}else {
					PageHelper.startPage(pageIndex, pageSize, true);
					List<LeaderInfo> selectList = leaderInfoMapper.selectList(queryWrapper);
					PageInfo<LeaderInfo> pageInfo = new PageInfo<>(selectList);	
					if (CollectionUtils.isNotEmpty(pageInfo.getList())) {	
							return pageInfo;
						}else {
							return new PageInfo<>();
						}
//					}
				}else {
					throw new Exception("未获取到页码相关信息");
				}
			}else {
				throw new Exception("未获取到登录用户信息id");
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Map<String, Object> submitInforForPerson(Map<String, Object> paramMap) {
		// TODO Auto-generated method stub
		Map<String, Object> resultMap = new HashMap<>();
		try {
			//获取邮箱信息
			List<MailInfo> mailInfoList = mailInfoMapper.selectList(new QueryWrapper<MailInfo>().eq("email_status", 2));
	        // 打乱集合顺序
	        Collections.shuffle(mailInfoList);
	        MailInfo mailInfo = new MailInfo();
	        if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(mailInfoList)) {
				mailInfo = mailInfoList.get(0);
			}
			if (paramMap.containsKey("stId") && paramMap.containsKey("guId")) {
				String stId = paramMap.get("stId").toString();
				String guId = paramMap.get("guId").toString();
				//获取旅行信息和护照信息
				PassportInfo passportInfo = passportInfoMapper.selectById(guId);
				if (Objects.nonNull(passportInfo)) {
					//获取旅行信息
					Malaysiatravinfo malaysiatravinfo = malaysiatravinfoMapper.selectById(stId);
					if (Objects.nonNull(malaysiatravinfo)) {
						Map<String, Object> hashMap = new HashMap<>();
						Map<String, Object> convertMalaysiaSubmitInfo = convertPassportSubmitInfo(passportInfo,"0060");
						Map<String, Object> convertMalaysiaTravelSubmitInfo = convertMalaysiaTravelSubmitInfo(malaysiatravinfo);
						if (Objects.nonNull(convertMalaysiaSubmitInfo) && Objects.nonNull(convertMalaysiaTravelSubmitInfo)) {
					        List<Map<String, Object>> submitList = new LinkedList<>();

							
					        hashMap.put("mdacVisaCountry","ALL");
							hashMap.put("submitRegistration","Submit");
							hashMap.put("email",mailInfo.getEmailLogin());
							hashMap.put("confirmEmail",mailInfo.getEmailLogin());
							
							hashMap.putAll(convertMalaysiaSubmitInfo);
							hashMap.putAll(convertMalaysiaTravelSubmitInfo);
							submitList.add(hashMap);
							
							if (submitList.size()==0) {
								throw new Exception("提交失败");
							}else {
					            // 开启线程
					            ExecutorService cacheThreadPool = Executors.newCachedThreadPool();
					            Callable<Boolean> clientAction = new Callable<Boolean>() {
					                @Override
					                public Boolean call() throws Exception {
					            		for (int i = 0; i < submitList.size(); i++) {
											Map<String, Object> submitMap = submitList.get(i);
											boolean register = malaysiaMadcRegUtil.register(submitMap);
											logger.error("执行成功："+register);
										}
					                    return true;
					                }
					            };
					            try {
					                cacheThreadPool.submit(clientAction);
					            } catch (Exception e) {
					                logger.error("执行clientAction失败:" + e.getMessage(), e);
					            } finally {
					                cacheThreadPool.shutdown();
					            }
							}
							resultMap.put("passpostList", passportInfo);
							resultMap.put("travelList", malaysiatravinfo);
						}
					}else {
						SingaporeTravInfo singaporeTravInfo = singaporeTravIndoMapper.selectById(stId);
						if (Objects.nonNull(singaporeTravInfo)) {
							
							Map<String, String> hashMap = new HashMap<>();
							Map<String, String> convertMalaysiaSubmitInfo = convertPassportSubmitInfo(passportInfo,"0065");
							Map<String, String> convertSingaporeTravelSubmitInfo = convertSingaporeTravelSubmitInfo(singaporeTravInfo);
							if (Objects.nonNull(convertMalaysiaSubmitInfo) && Objects.nonNull(convertSingaporeTravelSubmitInfo)) {
						        List<Map<String, String>> submitList = new LinkedList<>();

								
								resultMap.put("mdacVisaCountry","ALL");
								resultMap.put("submitRegistration","Submit");
								resultMap.put("email",mailInfo.getEmailLogin());
								resultMap.put("confirmEmail",mailInfo.getEmailLogin());
								
								hashMap.putAll(convertMalaysiaSubmitInfo);
								hashMap.putAll(convertSingaporeTravelSubmitInfo);
								submitList.add(hashMap);
								
								if (submitList.size()==0) {
									throw new Exception("提交失败");
								}else {
						            // 开启线程
						            ExecutorService cacheThreadPool = Executors.newCachedThreadPool();
						            Callable<Boolean> clientAction = new Callable<Boolean>() {
						                @Override
						                public Boolean call() throws Exception {
						            		for (int i = 0; i < submitList.size(); i++) {
												Map<String, String> submitMap = submitList.get(i);
												logger.error("新加坡开始执行开始-"+i+"："+JSON.toJSONString(submitMap));
												String[] register = SingaporeIcaRegUtil.register(chromeDriver,tempOcrDictionary, chromeCacheDictionary,submitMap,false);
												if (register.length==2) {
													String IDNumber = register[1];
													if (StringUtils.isNotEmpty(IDNumber)) {
														//获取并回写
														String titid = singaporeTravInfo.getTitid();
														//获取中间表
														List<Ordertravpassport> ordertravpassports = ordertravpassportMapper.selectList(new QueryWrapper<Ordertravpassport>().eq("travid", titid).eq("ecppid", guId));
														if (CollectionUtils.isNotEmpty(ordertravpassports)) {
															Ordertravpassport ordertravpassport = ordertravpassports.get(0);
															writeIdnumber(IDNumber, null, ordertravpassport.getId(), null, singaporeTravInfo,null);
														}
													}else {
														logger.error("新加坡开始执行结束-"+i+"："+register[2]);
													}
												}
											}
						                    return true;
						                }
						            };
						            try {
						                cacheThreadPool.submit(clientAction);
						            } catch (Exception e) {
						                logger.error("执行clientAction失败:" + e.getMessage(), e);
						            } finally {
						                cacheThreadPool.shutdown();
						            }
								}
								resultMap.put("passpostList", passportInfo);
								resultMap.put("travelList", malaysiatravinfo);
							}
						}else {
							ThailandTravInfo thailandTravInfo = thailanTravInfoMapper.selectById(stId);
							if (Objects.nonNull(thailandTravInfo)) {
								  // 开启线程
					            ExecutorService cacheThreadPool = Executors.newCachedThreadPool();
					            Callable<Boolean> clientAction = new Callable<Boolean>() {
					                @Override
					                public Boolean call() throws Exception {
					                	//执行泰国电子入境
					            		convertThailandTravelSubmitInfo(passportInfo, thailandTravInfo);
					            		//返回
					                    return true;
					                }
					            };
					            try {
					                cacheThreadPool.submit(clientAction);
					            } catch (Exception e) {
					                logger.error("执行clientAction失败:" + e.getMessage(), e);
					            } finally {
					                cacheThreadPool.shutdown();
					            }
								resultMap.put("passpostList", passportInfo);
								resultMap.put("travelList", thailandTravInfo);
							}else {
								throw new Exception("未获取到该用户旅行信息");
							}
						}
					}
				}else {
					throw new Exception("未获取到用户护照信息");
				}
			}else {
				throw new Exception("缺少关键信息id");
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
		return resultMap;
	}

	@Override
	public void writeIdnumber(String pins, String pinUrl, String otpId, Malaysiatravinfo malaysiatravinfo,SingaporeTravInfo singaporeTravInfo,ThailandTravInfo thailandTravInfo) {
		// TODO Auto-generated method stub
		try {
			logger.error("method:writeIdnumber-pins:"+pins+",otpId:"+otpId+",countryInfo"+malaysiatravinfo==null?JSON.toJSONString(singaporeTravInfo):JSON.toJSONString(malaysiatravinfo));
			if (StringUtils.isNotEmpty(pins)) {
				//创建pin码对象
				TravInfoCode travInfoCode = new TravInfoCode();
				String idString = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+new Date().getTime();
				travInfoCode.setId(idString);
				travInfoCode.setCode(pins);
				travInfoCode.setCodeUrl(pinUrl);
				travInfoCode.setPubts(new Date());
				travinfoCodeMapper.insert(travInfoCode);
				logger.error("写入pinCide:"+pins);
				int t = 0;
				if (malaysiatravinfo!=null) {
					t = malaysiatravinfo.getTrow();
				}else if (singaporeTravInfo!=null) {
					t = singaporeTravInfo.getTrow();
				}else if (thailandTravInfo!=null) {
					t = thailandTravInfo.getTrow();
				}
				//写入关系表
				TravelCodeRelation travelCodeRelation2 = new TravelCodeRelation();
				travelCodeRelation2.setId(StringUtil.getId());
				travelCodeRelation2.setOtpid(otpId);
				travelCodeRelation2.setTrow(t);
				travelCodeRelation2.setTcid(idString);
				travelCodeRelation2.setPubts(new Date());
				travelCodeRelationMapper.insert(travelCodeRelation2);
				logger.error("写入travelCodeRelation2:"+JSON.toJSONString(travelCodeRelation2));
			}
		} catch (Exception e) {
			// TODO: handle exception
			throw new RuntimeException(e.getMessage());
		}
	}

	@Autowired
	private TravbaoOrderMapper travbaoOrderMapper;
	
	public boolean istherearelatedorder(String trav_id, String passport_num, String entry_date) {
		boolean isexist = true;
		try {
			QueryWrapper<TravbaoOrder> queryWrapper = new QueryWrapper<>();
			queryWrapper.eq("trav_id", trav_id);
			queryWrapper.eq("entry_date", entry_date);
			queryWrapper.eq("passport_num", passport_num);
			List<TravbaoOrder> travbaoOrderList = travbaoOrderMapper.selectList(queryWrapper);
			if (travbaoOrderList.size()==0) {
				isexist = false;
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return isexist;
	};
	
	@Override
	public void insertTravbaoOrder(TravbaoOrder travbaoOrder) {
		// TODO Auto-generated method stub
		try {
			String id = StringUtil.getId();
			travbaoOrder.setId(id);
			travbaoOrder.setPubts(new Date());
			travbaoOrderMapper.insert(travbaoOrder);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
	
	//更新订单pin码
	public static final String updatePinCodeUrl = "https://www.travbao.com/goabraod/serve/updatePinCode.do";
	//获取订单参数接口
	public static final String initialSingaporeParamUrl = "https://www.travbao.com/goabraod/serve/getSingaporeOrderParam.do";
	
	
	@SuppressWarnings("unchecked")
	@Override
	public void initialSingaporeRequest() {
		// TODO Auto-generated method stub
		try {
			QueryWrapper<TravbaoOrder> queryWrapper = new QueryWrapper<>();
			queryWrapper.lt("retry_num", 3);
			queryWrapper.isNotNull("pin_code");
			queryWrapper.eq("is_lock", 0);
			List<TravbaoOrder> travbaoOrderList = travbaoOrderMapper.selectList(queryWrapper);
			travbaoOrderList.stream().forEach(t->{
				t.setIsLock((short)1);
				travbaoOrderMapper.updateById(t);
			});
			for (TravbaoOrder travbaoOrder : travbaoOrderList) {
				//获取相关参数
				String travId = travbaoOrder.getTravId();
				String passportNum = travbaoOrder.getPassportNum();
				//获取组装参数
				Map<String, Object> paramMap = new HashMap<>();
				paramMap.put("trav_id", travId);
				paramMap.put("passport_num", passportNum);
				//请求获取参数
				JSONObject jsonObject = HttpUtil.sendPost(initialSingaporeParamUrl, JSON.toJSONString(paramMap));
				if (Objects.nonNull(jsonObject)) {
					Integer code = jsonObject.getInteger("code");
					if (code==0) {
						Map<String,String> bodyMap = JSONObject.parseObject(jsonObject.getString("data"),Map.class);
						//请求参数
					    String[] register = SingaporeIcaRegUtil.register(chromeDriver, tempOcrDictionary, chromeCacheDictionary, bodyMap, false);
					    if (register.length>=2 && Objects.nonNull(register[1])) {
					    	for (int i = 0; i < register.length; i++) {
					    		logger.error("----------"+register[i]);
					    	}
							travbaoOrder.setPinCode(register[1]);
							travbaoOrderMapper.updateById(travbaoOrder);
							//回写pin码
							Map<String, Object> updatePinCodeParam = new HashMap<>();
							updatePinCodeParam.put("goId", travId);
							updatePinCodeParam.put("pinCode", register[1]);
							updatePinCodeParam.put("gu_passportnum", passportNum);
							JSONObject updatePinCodeParamObject = HttpUtil.sendPost(updatePinCodeUrl, JSON.toJSONString(updatePinCodeParam));
							if (Objects.nonNull(updatePinCodeParamObject)) {
								Integer integer = updatePinCodeParamObject.getInteger("code");
								if (integer==0) {
									logger.error("------新加坡回写成功-----"+register[1]);
								}
							}
						}else {
							Integer retryNum = travbaoOrder.getRetryNum()+1;
							travbaoOrder.setRetryNum(retryNum);
							travbaoOrderMapper.updateById(travbaoOrder);
						}
					}else {
						Integer retryNum = travbaoOrder.getRetryNum()+1;
						travbaoOrder.setRetryNum(retryNum);
						travbaoOrderMapper.updateById(travbaoOrder);
					}
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
	
	
	@Override
	public Map<String, Object> selectTravelitineraryInfo(String travId) {
		// TODO Auto-generated method stub
		Map<String, Object> resultMap = new HashMap<>();
		try {
			//获取旅行信息
			Travelitinerary travelitinerary = travelitineraryMapper.selectById(travId);
			if (Objects.nonNull(travelitinerary)) {
				String titCode = travelitinerary.getTitCode();
				//判断旅行行程
				String[] titArr = titCode.split("-");
				resultMap.put("titNum", titArr.length);
				Map<String, Object> travelMap = new HashMap<>();
				for (int i = 0; i < titArr.length; i++) {
					String trow = String.valueOf(i+1);
					String titArrId = titArr[i];
					//获取旅行信息
					if (Objects.equals(titArrId, "0060")) {
						Malaysiatravinfo malaysiatravinfo = malaysiatravinfoMapper.selectOne(new QueryWrapper<Malaysiatravinfo>().eq("titId", travId).eq("trow", trow));
						travelMap.put(trow, malaysiatravinfo);
					}else if (Objects.equals(titArrId, "0065")) {
						SingaporeTravInfo singaporeTravInfo = singaporeTravIndoMapper.selectOne(new QueryWrapper<SingaporeTravInfo>().eq("titId", travId).eq("trow", trow));
						travelMap.put(trow, singaporeTravInfo);
					}else if (Objects.equals(titArrId, "0066")) {
						ThailandTravInfo thailandTravInfo = thailanTravInfoMapper.selectOne(new QueryWrapper<ThailandTravInfo>().eq("titId", travId).eq("trow", trow));
						travelMap.put(trow, thailandTravInfo);
					}
				}
				resultMap.put("travelInfo", travelMap);
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return resultMap;
	}
}
